使用的拓扑:
R1(S1/1)--(S1/0)R2(S1/1)--(S1/0)R3
BGP 64512:R1 R2
BGP 64513:R3
R1#show run
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface Loopback1
ip address 172.16.0.1 255.255.255.0
!
interface Loopback2
ip address 172.16.1.1 255.255.255.0
!
interface Loopback3
ip address 172.16.2.1 255.255.255.0
!
interface Loopback4
ip address 172.16.3.1 255.255.255.0
!
ip address 1.1.1.1 255.255.255.255
!
interface Loopback1
ip address 172.16.0.1 255.255.255.0
!
interface Loopback2
ip address 172.16.1.1 255.255.255.0
!
interface Loopback3
ip address 172.16.2.1 255.255.255.0
!
interface Loopback4
ip address 172.16.3.1 255.255.255.0
!
interface Serial1/1
description DCE,BGP,connected to R1's S1/0,ip 172.16.255.2/30
ip address 172.16.255.1 255.255.255.252
clock rate 9600
!
description DCE,BGP,connected to R1's S1/0,ip 172.16.255.2/30
ip address 172.16.255.1 255.255.255.252
clock rate 9600
!
router bgp 64512
no synchronization network 172.16.0.0 mask 255.255.252.0 neighbor 2.2.2.2 remote-as 64512
neighbor 2.2.2.2 update-source Loopback0
no auto-summary
!
ip route 2.2.2.2 255.255.255.255 Serial1/1
ip route 3.3.3.3 255.255.255.255 Serial1/1 ip route 172.16.0.0 255.255.252.0 Null0
no synchronization network 172.16.0.0 mask 255.255.252.0 neighbor 2.2.2.2 remote-as 64512
neighbor 2.2.2.2 update-source Loopback0
no auto-summary
!
ip route 2.2.2.2 255.255.255.255 Serial1/1
ip route 3.3.3.3 255.255.255.255 Serial1/1 ip route 172.16.0.0 255.255.252.0 Null0
/
R2#show run
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
description DTE,BGP 64512,connected to R1's S1/1,ip 172.16.255.1/30
ip address 172.16.255.2 255.255.255.252
!
interface Serial1/1
description description DCE,BGP 64512,connected to R3's S1/0,ip 10.1.255.2/30
ip address 10.1.255.1 255.255.255.252
clock rate 9600
!
ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
description DTE,BGP 64512,connected to R1's S1/1,ip 172.16.255.1/30
ip address 172.16.255.2 255.255.255.252
!
interface Serial1/1
description description DCE,BGP 64512,connected to R3's S1/0,ip 10.1.255.2/30
ip address 10.1.255.1 255.255.255.252
clock rate 9600
!
router bgp 64512
no synchronization
neighbor 1.1.1.1 remote-as 64512
neighbor 1.1.1.1 update-source Loopback0
neighbor 3.3.3.3 remote-as 64513
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
!
ip route 1.1.1.1 255.255.255.255 Serial1/0
ip route 3.3.3.3 255.255.255.255 Serial1/1
no synchronization
neighbor 1.1.1.1 remote-as 64512
neighbor 1.1.1.1 update-source Loopback0
neighbor 3.3.3.3 remote-as 64513
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
!
ip route 1.1.1.1 255.255.255.255 Serial1/0
ip route 3.3.3.3 255.255.255.255 Serial1/1
/
R3#show run
interface Loopback0
ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
ip address 192.168.0.1 255.255.255.0
!
interface Loopback2
ip address 192.168.1.1 255.255.255.0
!
interface Loopback3
ip address 192.168.2.1 255.255.255.0
!
interface Loopback4
ip address 192.168.3.1 255.255.255.0
!
ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
ip address 192.168.0.1 255.255.255.0
!
interface Loopback2
ip address 192.168.1.1 255.255.255.0
!
interface Loopback3
ip address 192.168.2.1 255.255.255.0
!
interface Loopback4
ip address 192.168.3.1 255.255.255.0
!
interface Serial1/0
description DTE,BGP 64513,connected to R2's S1/1,ip 10.1.255.1/30
ip address 10.1.255.2 255.255.255.252
!
description DTE,BGP 64513,connected to R2's S1/1,ip 10.1.255.1/30
ip address 10.1.255.2 255.255.255.252
!
router bgp 64513
no synchronization network 192.168.0.0 mask 255.255.252.0 neighbor 2.2.2.2 remote-as 64512
neighbor 2.2.2.2 ebgp-multihop 2
neighbor 2.2.2.2 update-source Loopback0
no auto-summary
!
ip classless
ip route 2.2.2.2 255.255.255.255 Serial1/0 ip route 192.168.0.0 255.255.252.0 Null0
no synchronization network 192.168.0.0 mask 255.255.252.0 neighbor 2.2.2.2 remote-as 64512
neighbor 2.2.2.2 ebgp-multihop 2
neighbor 2.2.2.2 update-source Loopback0
no auto-summary
!
ip classless
ip route 2.2.2.2 255.255.255.255 Serial1/0 ip route 192.168.0.0 255.255.252.0 Null0
/
这里使用除auto-summary外的另一种方法汇总路由。由于bgp发布的路由必须是路由表中明文存在的,因此这里使用指明一条到null0的静态路由,内容为lo口的汇总,由bgp发布,当数据包匹配该路由时,根据路由选择中最长掩码最优先匹配的原则,就会由lo端口负责处理。原理与自动汇总一致。而且可以随意指定汇总的掩码长度,更加灵活。
本来以为汇总问题解决了,但使用ping验证连接性时却出现了问题。
R1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R3#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
进入最枯燥的排错环节。首先是定位错误发生的地点。
R1#traceroute 192.168.1.1
Type escape sequence to abort.
Tracing the route to 192.168.1.1
Tracing the route to 192.168.1.1
1 172.16.255.2 20 msec 28 msec 32 msec
2 * * *
2 * * *
可见数据包到达了R2,接着在R2上测试
R2#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/30/40 ms
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/30/40 ms
可见R1->R2,R2->R3,R3->R2都没有问题,关键是R2->R1的时候出了问题。由于数据报目的地为R3,在R3使用调试
R3#debug ip icmp
在R1上使用ping,检查R3的调试结果
R3#
*May 17 10:28:25.427: ICMP: dst (192.168.1.1) port unreachable sent to 172.16.255.1
*May 17 10:28:25.427: ICMP: dst (192.168.1.1) port unreachable sent to 172.16.255.1
终于发现问题了,由于之前为了缩减路由表的数量,把所有serial线路上的路由发布都去掉了。既然如此,问题解决就简单了。
R2(config)#router bgp 64512
R2(config-router)#net 172.16.255.0 mask 255.255.255.252
R2(config-router)#net 192.168.255.0 mask 255.255.255.252
R2(config-router)#net 172.16.255.0 mask 255.255.255.252
R2(config-router)#net 192.168.255.0 mask 255.255.255.252
让R2通告两台串联链路的路由,问题解决
R1#ping 192.168.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/67/96 ms
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/67/96 ms
另外还有一种使用aggregate-address的方式,从试验来看没有什么差别。虽然书上讲使用static null0可能导致其他路由器无法识别生成汇总的路由器,但从实验上看,R3看到的汇总依然是由R2生成的。理论上讲,由于aggregate-address只在bgp进程里有效,但由于aggregate是bgp的属性(我不是很确定是否相关),因此若该汇总若只针对bgp,则最好使用aggregate-address;若其它进程有可能调用该路由(如route-map),则最好使用static null0。
有关内容可参考此帖: