在聚合路由的同时配置条件性通过操作,可以在一定程度上避免无效的流量转发到目的网络以及路由黑洞等问题。
在BGP路由聚合的场景中,到达目的网络的前提是至少要有一条被优选的路由,否则聚合不会生效。另外,BGP在默认情况下每隔一段时间会执行路由聚合检测机制。
实验拓扑图如下所示:
首先做BGP的邻居建立与网络前缀、聚合路由通告以及条件性通告的基本配置使网络可达性和连通性。因上个实验已经一步步实现,所以本实验是一次性达成上个实验的效果。除了直接在R1和R2上做路由聚合同时抑制明细路由并将聚合检测时间参数设置为0,直接看配置和验证结果。
R1的基础配置:
hostname R1
!
interface Loopback0
ip address 172.22.0.1 255.255.255.0
!
interface Loopback1
ip address 172.22.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 10.0.12.1 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.1.13.1 255.255.255.0
no sh
!
router bgp 111
bgp router-id 1.1.1.1
bgp aggregate-timer 0
network 172.22.0.0 mask 255.255.255.0
network 172.22.1.0 mask 255.255.255.0
aggregate-address 172.22.0.0 255.255.254.0 summary-only
neighbor 10.0.12.2 remote-as 222
neighbor 10.1.13.3 remote-as 345
!
end
R2的基础配置:
hostname R2
!
interface Loopback0
ip address 172.22.2.2 255.255.255.0
!
interface Loopback1
ip address 172.22.3.2 255.255.255.0
!
interface Ethernet0/0
ip address 10.0.12.2 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.2.24.2 255.255.255.0
no sh
!
router bgp 222
bgp router-id 2.2.2.2
bgp aggregate-timer 0
network 172.22.2.0 mask 255.255.255.0
network 172.22.3.0 mask 255.255.255.0
aggregate-address 172.22.2.0 255.255.254.0 summary-only
neighbor 10.0.12.1 remote-as 111
neighbor 10.2.24.4 remote-as 345
!
end
R3的基础配置:
hostname R3
!
interface Loopback3
ip address 192.168.3.3 255.255.255.255
!
interface Ethernet0/0
ip address 10.1.13.3 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.3.35.3 255.255.255.0
no sh
!
router eigrp 5
network 0.0.0.0
passive-interface Ethernet0/0
!
router bgp 345
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor IBGP peer-group
neighbor IBGP remote-as 345
neighbor IBGP update-source Loopback3
neighbor IBGP next-hop-self
neighbor 10.1.13.1 remote-as 111
neighbor 192.168.4.4 peer-group IBGP
neighbor 192.168.5.5 peer-group IBGP
!
end
R4的基础配置:
hostname R4
!
interface Loopback4
ip address 192.168.4.4 255.255.255.255
!
interface Ethernet0/0
ip address 10.2.24.4 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.3.45.4 255.255.255.0
no sh
!
router eigrp 5
network 0.0.0.0
passive-interface Ethernet0/0
!
router bgp 345
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor IBGP peer-group
neighbor IBGP remote-as 345
neighbor IBGP update-source Loopback4
neighbor IBGP next-hop-self
neighbor 10.2.24.2 remote-as 222
neighbor 192.168.3.3 peer-group IBGP
neighbor 192.168.5.5 peer-group IBGP
!
end
R5的基础配置:
hostname R5
!
interface Loopback0
ip address 172.23.0.5 255.255.255.0
!
interface Loopback1
ip address 172.23.1.5 255.255.255.0
!
interface Loopback2
ip address 172.23.2.5 255.255.255.0
!
interface Loopback3
ip address 172.23.3.5 255.255.255.0
!
interface Loopback5
ip address 192.168.5.5 255.255.255.255
!
interface Ethernet0/0
ip address 10.3.35.5 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.3.45.5 255.255.255.0
no sh
!
router eigrp 5
network 0.0.0.0
passive-interface default
no passive-interface Ethernet0/0
no passive-interface Ethernet0/1
!
route-map REDCONN permit 10
match interface Loopback0 Loopback1 Loopback2 Loopback3
!
router bgp 345
bgp router-id 5.5.5.5
bgp log-neighbor-changes
bgp listen range 192.168.0.0/21 peer-group IBGP
redistribute connected route-map REDCONN
neighbor IBGP peer-group
neighbor IBGP remote-as 345
neighbor IBGP update-source Loopback5
!
end
根据以上配置,分别查看路由器R1、R2、R3、R4、R5的BGP表为:
以上路由器上的BGP路由表为:
现在更改一下路由聚合的范围,再更改路由泄漏条目,具体操作如下:
R1的修改配置更改为:
router bgp 111
no aggregate-address 172.22.0.0 255.255.254.0 summary-only
aggregate-address 172.22.0.0 255.255.252.0 summary-only
R2的修改配置更改为:
router bgp 222
no aggregate-address 172.22.2.0 255.255.254.0 summary-only
aggregate-address 172.22.0.0 255.255.252.0 summary-only
再查看所有路由器的BGP表如下所示:
以上可以看到改变了聚合长度,在网络边界的路由走向也可能随之发生了改变,R1、R2、R5。
现在在R1上设置一个部署条件为:仅当172.22.3.0/24的网络存在R1的BGP表中时,R1才向R3通告聚合网络172.22.0.0/22的路由,修改参数及示例如下:
R1的添加配置为:
ip prefix-list IFN3 seq 5 permit 172.22.3.0/24
!
ip prefix-list IFN3ADV seq 5 permit 172.22.0.0/22
!
route-map IFN3 permit 10
match ip address prefix-list IFN3
!
route-map IFN3ADV permit 10
match ip address prefix-list IFN3ADV
!
router bgp 111
neighbor 10.1.13.3 advertise-map IFN3ADV exist-map IFN3
!
由于R2已经抑制172.22.3.0/24的网络,所以查看如下BGP表所示为:
现在在R2上再做条件性控制,让R2的172.22.3.0/24的网络泄露给R1,即再次匹配R1设置的触发条件的效果如下配置和验证所示:
在R2上添加配置如下:
ip prefix-list IFN3E seq 5 permit 172.22.3.0/24
!
route-map LEAK3 permit 10
match ip address prefix-list IFN3E
!
router bgp 222
neighbor 10.0.12.1 unsuppress-map LEAK3
在聚合路由的同时实施条件性通告,可以在一定程度上避免无效的流量转发以及路由黑洞的问题。