配置公私网路由相互引入功能示例
流量清洗场景中,可以在设备上配置公私网路由相互引入功能,将公网路由引入到VPN私网中,指导回注流量的转发。
组网需求
如图7-32所示,DeviceA属于AS100,B、DeviceC和Server属于AS200,DeviceB为AS200的网络入口设备。AS200通过DeviceB可以与AS100相互通信。
当AS100内出现攻击源时,攻击流量通过DeviceB流入到AS200内对AS200的网络造成了危害,部署流量清洗服务器后可将流量引入到清洗服务器Server中进行清洗。清洗后的流量通过DeviceB回注到AS200网络中,此时需要在DeviceB的私网路由表中引入DeviceC的公网路由使清洗后的回注流量转发至DeviceC,同时不引入Server发出的公网路由,防止回注流量到达DeviceB后,又发回给Server而造成环路。对于上述过程,可以通过在DeviceB上配置公私网路由相互引入功能并基于BGP邻居配置路由策略实现。
设备 |
接口 |
IP地址 |
---|---|---|
DeviceA |
Loopback1 |
1.1.1.1/32 |
GE1/0/0 |
10.1.1.1/24 |
|
DeviceB |
Loopback1 |
2.2.2.2/32 |
GE1/0/0 |
10.1.1.2/24 |
|
GE2/0/0 |
10.2.3.1/24 |
|
GE2/0/0.1 |
10.2.1.1/24 |
|
GE2/0/0.2 |
10.2.2.1/24 |
|
GE3/0/0 |
172.16.1.1/24 |
|
DeviceC |
Loopback1 |
3.3.3.3/32 |
GE1/0/0 |
172.16.1.2/24 |
|
Server |
Loopback1 |
4.4.4.4/32 |
GE1/0/0 |
10.2.3.2/24 |
|
GE1/0/0.1 |
10.2.1.2/24 |
|
GE1/0/0.2 |
10.2.2.2/24 |
配置思路
采用如下的思路配置公私网路由相互引入功能:
配置各接口的IP地址。
- 在DeviceB、DeviceC、Server上配置OSPF功能。
在DeviceB和DeviceC、DeviceB和Server之间配置IBGP连接。
在DeviceA和DeviceB之间配置EBGP连接。
配置DeviceB上与Server相连的接口绑定VPN;在DeviceB上配置路由策略,使私网路由表中不引入由Server发过来的路由。
- 在Server上配置32位掩码的静态路由并引入BGP路由表中,在DeviceC上配置16位掩码的静态路由并引入BGP路由表中。根据路由最长匹配原则,将DeviceA发来的流量引到Server设备,模拟流量清洗过程。
- 在DeviceB上配置公私网路由相互引入功能,将公网路由引入私网路由表中,指导回注流量转发至DeviceC。
流量分析服务器Server为第三方设备,此示例模拟Server只提供基础的BGP配置、OSPF配置、静态路由引入BGP路由的配置,其他流量清洗相关配置略。
数据准备
DeviceA、DeviceB、DeviceC的Router ID。
DeviceA的自治系统号为100,DeviceB、DeviceC、Server的自治系统号为200。
vpna的收发路由属性VPN-Target。
DeviceB上配置的路由策略。
- DeviceC、Server发布的路由。
操作步骤
- 配置各接口的IP地址。
具体配置请参见配置文件。
- 配置OSPF。
# 配置DeviceB。
[~DeviceB] ospf 1
[*DeviceB-ospf-1] area 0
[*DeviceB-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] network 10.2.2.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] network 10.2.3.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255
[*DeviceB-ospf-1-area-0.0.0.0] network 2.2.2.2 0.0.0.0
[*DeviceB-ospf-1-area-0.0.0.0] commit
[~DeviceB-ospf-1-area-0.0.0.0] quit
[~DeviceB-ospf-1] quit
# 配置DeviceC。
[~DeviceC] ospf 1
[*DeviceC-ospf-1] area 0
[*DeviceC-ospf-1-area-0.0.0.0] network 172.16.1.0 0.0.0.255
[*DeviceC-ospf-1-area-0.0.0.0] network 3.3.3.3 0.0.0.0
[*DeviceC-ospf-1-area-0.0.0.0] commit
[~DeviceC-ospf-1-area-0.0.0.0] quit
[~DeviceC-ospf-1] quit
# 配置Server。
[~Server] ospf 1
[*Server-ospf-1] area 0
[*Server-ospf-1-area-0.0.0.0] network 10.2.1.0 0.0.0.255
[*Server-ospf-1-area-0.0.0.0] network 10.2.2.0 0.0.0.0
[*Server-ospf-1-area-0.0.0.0] commit
[~Server-ospf-1-area-0.0.0.0] quit
[~Server-ospf-1] quit
- 配置IBGP连接。
# 配置DeviceB。
[~DeviceB] bgp 200
[*DeviceB-bgp] router-id 2.2.2.2
[*DeviceB-bgp] peer 10.2.3.2 as-number 200
[*DeviceB-bgp] peer 172.16.1.2 as-number 200
[*DeviceB-bgp] import-route ospf 1
[*DeviceB-bgp] commit
[~DeviceB-bgp] quit
# 配置DeviceC。
[~DeviceC] bgp 200
[*DeviceC-bgp] router-id 3.3.3.3
[*DeviceC-bgp] peer 172.16.1.1 as-number 200
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
# 配置Server。
[~Server] bgp 200
[*Server-bgp] router-id 4.4.4.4
[*Server-bgp] peer 10.2.3.1 as-number 200
[*Server-bgp] import-route direct
[*Server-bgp] commit
[~Server-bgp] quit
- 配置EBGP连接。
# 配置DeviceA。
[~DeviceA] bgp 100
[*DeviceA-bgp] router-id 1.1.1.1
[*DeviceA-bgp] peer 10.1.1.2 as-number 200
[*DeviceA-bgp] import-route direct
[*DeviceA-bgp] commit
[~DeviceA-bgp] quit
# 配置DeviceB。
[~DeviceB] bgp 200
[*DeviceB-bgp] peer 10.1.1.1 as-number 100
[*DeviceB-bgp] commit
[~DeviceB-bgp] quit
- 创建VPN,配置接口绑定VPN,并配置路由策略。
# 配置DeviceB。
[~DeviceB]ip vpn-instance vpna
[*DeviceB-vpn-instance-vpna] ipv4-family
[*DeviceB-vpn-instance-vpna-af-ipv4] route-distinguisher 100:1
[*DeviceB-vpn-instance-vpna-af-ipv4] vpn-target 111:1 both
[*DeviceB-vpn-instance-vpna-af-ipv4] quit
[*DeviceB-vpn-instance-vpna] quit
[*DeviceB] interface GigabitEthernet2/0/0.2
[*DeviceB-GigabitEthernet2/0/0.2] ip binding vpn-instance vpna
[*DeviceB-GigabitEthernet2/0/0.2] ip address 10.2.2.1 24
[*DeviceB-GigabitEthernet2/0/0.2] quit
[*DeviceB] ip community-filter basic serverRoute index 10 permit 100:100
[*DeviceB] route-policy noexportServer deny node 10
[*DeviceB-route-policy] if-match community-filter serverRoute
[*DeviceB-route-policy] quit
[*DeviceB] route-policy noexportServer permit node 100
[*DeviceB-route-policy] quit
[*DeviceB] route-policy setCom permit node 10
[*DeviceB-route-policy] apply community 100:100
[*DeviceB-route-policy] quit
[*DeviceB] bgp 200
[*DeviceB-bgp] peer 10.2.3.2 route-policy setCom import
[*DeviceB-bgp] quit
[*DeviceB] commit
- 在DeviceC、Server上配置静态路由引入BGP路由表,根据路由最长匹配原则,模拟将流量引到Server。
# 配置DeviceC。
[~DeviceC] ip route-static 33.33.0.0 16 NULL 0
[~DeviceC] bgp 200
[*DeviceC-bgp] network 33.33.0.0 16
[*DeviceC-bgp] commit
[~DeviceC-bgp] quit
# 配置Server。
[~Server] ip route-static 33.33.33.33 32 NULL 0
[~Server] bgp 200
[*Server-bgp] network 33.33.33.33 32
[*Server-bgp] commit
[~Server-bgp] quit
- 在DeviceB上配置公网BGP路由引入私网路由表。通过发布路由来模拟流量,实现指导回注流量转发到DeviceC。
# 配置DeviceB。
[~DeviceB] bgp 200
[*DeviceB-bgp] ipv4-family vpn-instance vpna
[*DeviceB-bgp-vpna] import-rib public route-policy noexportServer
[*DeviceB-bgp] commit
[~DeviceB-bgp] quit
- 检查配置结果
# 在DeviceB上查看BGP公网路由表,可以看到从DeviceA、DeviceC和Server学习到公网路由。如果有去往33.33.0.0网段地址的流量,根据路由最长匹配原则,会优选33.33.33.33/32 10.2.3.2 此路由,先到达Server。
<DeviceB> display bgp routing-table
BGP Local router ID is 2.2.2.2 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete RPKI validation codes: V - valid, I - invalid, N - not-found Total Number of Routes: 9 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 10.1.1.1 0 0 100? *> 2.2.2.2/32 0.0.0.0 0 0 ? *>i 4.4.4.4/32 10.2.3.2 0 100 0 ? 10.1.1.0/24 10.1.1.1 0 0 100? *> 10.2.3.0/24 0.0.0.0 0 0 ? i 10.2.3.2 0 100 0 ? *>i 33.33.0.0/16 172.16.1.2 0 100 0 i *>i 33.33.33.33/32 10.2.3.2 0 100 0 i *> 172.16.1.0/24 0.0.0.0 0 0 ?
# 在DeviceB上查看BGP私网路由表,可以看到公网BGP路由被引入到私网路由表中,且没有从Server学习到公网路由。Server回注的流量会选择33.33.0.0/16 172.16.1.2路由返回给DeviceC。
<DeviceB> display bgp vpnv4 vpn-instance vpna routing-table
BGP Local router ID is 2.2.2.2 Status codes: * - valid, > - best, d - damped, x - best external, a - add path, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete RPKI validation codes: V - valid, I - invalid, N - not-found VPN-Instance vpna, Router ID 2.2.2.2: Total Number of Routes: 2 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 10.1.1.1 0 0 100? *>i 33.33.0.0/16 172.16.1.2 0 100 0 i
# 在DeviceB上查看BGP私网路由表,可以看到去往33.33.33.33地址的路由下一跳为DeviceC的出接口。
<DeviceB> display bgp vpnv4 vpn-instance vpna routing-table 33.33.33.33
BGP local router ID : 2.2.2.2 Local AS number : 200 VPN-Instance vpna, Router ID 2.2.2.2: Paths: 1 available, 1 best, 1 select, 0 best-external, 0 add-path BGP routing table entry information of 33.33.0.0/16: Route Distinguisher: 100:1 From: 172.16.1.2 (3.3.3.3) Route Duration: 0d03h12m45s Relay IP Nexthop: 172.16.1.2 Relay IP Out-Interface: GigabitEthernet3/0/0 Original nexthop: 172.16.1.2 Qos information : 0x0 Primary Routing Table: public AS-path Nil, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, pre 255 Not advertised to any peer yet
完成上述配置后,DeviceB的私网路由表中引入了到达DeviceC的公网路由,从Server发送的回注流量报文通过DeviceB被转发到DeviceC上,且由于DeviceB的私网路由表中没有引入到Server的公网路由,因此避免了环路的产生。
配置文件
DeviceA的配置文件
sysname DeviceA # interface GigabitEthernet1/0/0 undo shutdown ip address 10.1.1.1 255.255.255.0 # interface LoopBack1 ip address 1.1.1.1 255.255.255.255 # bgp 100 router-id 1.1.1.1 peer 10.1.1.2 as-number 200 # ipv4-family unicast undo synchronization import-route direct peer 10.1.1.2 enable # return
DeviceB的配置文件
# sysname DeviceB # ip vpn-instance vpna ipv4-family route-distinguisher 100:1 apply-label per-instance vpn-target 111:1 export-extcommunity vpn-target 111:1 import-extcommunity # interface GigabitEthernet1/0/0 undo shutdown ip address 10.1.1.2 255.255.255.0 # interface GigabitEthernet2/0/0 undo shutdown ip address 10.2.3.1 255.255.255.0 # interface GigabitEthernet2/0/0.1 ip address 10.2.1.1 255.255.255.0 # interface GigabitEthernet2/0/0.2 ip binding vpn-instance vpna ip address 10.2.2.1 255.255.255.0 # interface GigabitEthernet3/0/0 undo shutdown ip address 172.16.1.1 255.255.255.0 # interface LoopBack1 ip address 2.2.2.2 255.255.255.255 # bgp 200 router-id 2.2.2.2 peer 10.1.1.1 as-number 100 peer 10.2.3.2 as-number 200 peer 172.16.1.2 as-number 200 # ipv4-family unicast undo synchronization import-route ospf 1 peer 10.1.1.1 enable peer 10.2.3.2 enable peer 10.2.3.2 route-policy setCom import peer 172.16.1.2 enable # ipv4-family vpn-instance vpna import-rib public route-policy noexportServer # ospf 1 area 0.0.0.0 network 2.2.2.2 0.0.0.0 network 10.2.1.0 0.0.0.255 network 10.2.2.0 0.0.0.255 network 10.2.3.0 0.0.0.255 network 172.16.1.0 0.0.0.255 # route-policy noexportServer deny node 10 if-match community-filter serverRoute # route-policy noexportServer permit node 100 # route-policy setCom permit node 10 apply community 100:100 # ip community-filter basic serverRoute index 10 permit 100:100 # return
DeviceC的配置文件
sysname DeviceC # interface GigabitEthernet1/0/0 undo shutdown ip address 172.16.1.2 255.255.255.0 # bgp 200 router-id 3.3.3.3 peer 172.16.1.1 as-number 200 # ipv4-family unicast undo synchronization network 33.33.0.0 255.255.0.0 peer 172.16.1.1 enable # ospf 1 area 0.0.0.0 network 3.3.3.3 0.0.0.0 network 172.16.1.0 0.0.0.255 # ip route-static 33.33.0.0 255.255.0.0 NULL0 # return
Server的配置文件
sysname Server # interface GigabitEthernet1/0/0 undo shutdown ip address 10.2.3.2 255.255.255.0 # interface GigabitEthernet1/0/0.1 ip address 10.2.1.2 255.255.255.0 # interface GigabitEthernet1/0/0.2 ip address 10.2.2.2 255.255.255.0 # interface LoopBack1 ip address 4.4.4.4 255.255.255.255 # bgp 200 router-id 4.4.4.4 peer 10.2.3.1 as-number 200 # ipv4-family unicast undo synchronization network 33.33.33.33 255.255.255.255 import-route direct peer 10.2.3.1 enable # ospf 1 area 0.0.0.0 network 4.4.4.4 0.0.0.0 network 10.2.1.0 0.0.0.255 network 10.2.2.0 0.0.0.255 # ip route-static 33.33.33.33 255.255.255.255 NULL0 # return