拓扑
配置
- R1、R2、R3、R4之间运行OSPF
- R1与R5运行EBGP
- R4与R6运行EBGP
- R1与R4通过g0/0口运行IBGP
R1#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 12.1.1.1 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R1#sh run | s r o
router ospf 1
router-id 1.1.1.1
network 1.1.1.1 0.0.0.0 area 0
network 12.1.1.1 0.0.0.0 area 0
network 15.1.1.1 0.0.0.0 area 0
R1#sh run | s r b
router bgp 1234
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 15.1.1.5 remote-as 500
neighbor 34.1.1.4 remote-as 1234
R2#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 12.1.1.2 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R2#sh run | s r o
router ospf 1
router-id 2.2.2.2
network 2.2.2.2 0.0.0.0 area 0
network 12.1.1.2 0.0.0.0 area 0
network 23.1.1.2 0.0.0.0 area 0
R2#sh run | s r b
R2#
R3#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 23.1.1.3 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R3#sh run | s r o
router ospf 1
router-id 3.3.3.3
network 3.3.3.3 0.0.0.0 area 0
network 23.1.1.3 0.0.0.0 area 0
network 34.1.1.3 0.0.0.0 area 0
R3#sh run | s r b
R3#
R4#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 34.1.1.4 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R4#sh run | s r o
router ospf 1
router-id 4.4.4.4
network 4.4.4.4 0.0.0.0 area 0
network 34.1.1.4 0.0.0.0 area 0
network 46.1.1.4 0.0.0.0 area 0
R4#sh run | s r b
router bgp 1234
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor 12.1.1.1 remote-as 1234
neighbor 46.1.1.6 remote-as 600
R5#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 15.1.1.5 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R5#sh run | s r o
R5#sh run | s r b
router bgp 500
bgp router-id 5.5.5.5
bgp log-neighbor-changes
network 5.5.5.5 mask 255.255.255.255
neighbor 15.1.1.1 remote-as 1234
R6#sh run int g0/0
Building configuration...
Current configuration : 131 bytes
!
interface GigabitEthernet0/0
ip address 46.1.1.6 255.255.255.0
duplex full
speed 1000
media-type gbic
negotiation auto
end
R6#sh run | s r o
R6#sh run | s r b
router bgp 600
bgp router-id 6.6.6.6
bgp log-neighbor-changes
network 6.6.6.6 mask 255.255.255.255
neighbor 46.1.1.4 remote-as 1234
查看BGP邻居和路由条目
R1#sh bgp summary
BGP router identifier 1.1.1.1, local AS number 1234
BGP table version is 7, main routing table version 7
2 network entries using 296 bytes of memory
2 path entries using 128 bytes of memory
2/2 BGP path/bestpath attribute entries using 272 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 744 total bytes of memory
BGP activity 4/2 prefixes, 4/2 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
15.1.1.5 4 500 686 697 7 0 0 10:30:14 1
34.1.1.4 4 1234 663 667 7 0 0 10:02:09 1
R1#sh ip bgp
BGP table version is 7, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 5.5.5.5/32 15.1.1.5 0 0 500 i
*>i 6.6.6.6/32 46.1.1.6 0 100 0 600 i
R1#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 12.1.1.2, 10:43:02, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/3] via 12.1.1.2, 10:40:40, GigabitEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/4] via 12.1.1.2, 10:39:30, GigabitEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [20/0] via 15.1.1.5, 10:30:24
6.0.0.0/32 is subnetted, 1 subnets
B 6.6.6.6 [200/0] via 46.1.1.6, 09:59:34
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.1/32 is directly connected, GigabitEthernet0/0
15.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 15.1.1.0/24 is directly connected, GigabitEthernet1/0
L 15.1.1.1/32 is directly connected, GigabitEthernet1/0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/2] via 12.1.1.2, 10:42:52, GigabitEthernet0/0
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/3] via 12.1.1.2, 10:40:40, GigabitEthernet0/0
46.0.0.0/24 is subnetted, 1 subnets
O 46.1.1.0 [110/4] via 12.1.1.2, 09:59:39, GigabitEthernet0/0
R2#sh bgp summary
% BGP not active
R2#sh ip bgp
% BGP not active
R2#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/2] via 12.1.1.1, 10:33:07, GigabitEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 23.1.1.3, 10:30:47, GigabitEthernet1/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/3] via 23.1.1.3, 10:29:18, GigabitEthernet1/0
12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 12.1.1.0/24 is directly connected, GigabitEthernet0/0
L 12.1.1.2/32 is directly connected, GigabitEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
O 15.1.1.0 [110/2] via 12.1.1.1, 09:49:57, GigabitEthernet0/0
23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 23.1.1.0/24 is directly connected, GigabitEthernet1/0
L 23.1.1.2/32 is directly connected, GigabitEthernet1/0
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/2] via 23.1.1.3, 10:30:47, GigabitEthernet1/0
46.0.0.0/24 is subnetted, 1 subnets
O 46.1.1.0 [110/3] via 23.1.1.3, 09:50:18, GigabitEthernet1/0
R3#sh bgp summary
% BGP not active
R3#sh ip bgp
% BGP not active
R3#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/3] via 23.1.1.2, 10:30:36, GigabitEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 23.1.1.2, 10:30:36, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/2] via 34.1.1.4, 10:29:17, GigabitEthernet1/0
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/2] via 23.1.1.2, 10:30:36, GigabitEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
O 15.1.1.0 [110/3] via 23.1.1.2, 09:49:48, GigabitEthernet0/0
23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 23.1.1.0/24 is directly connected, GigabitEthernet0/0
L 23.1.1.3/32 is directly connected, GigabitEthernet0/0
34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 34.1.1.0/24 is directly connected, GigabitEthernet1/0
L 34.1.1.3/32 is directly connected, GigabitEthernet1/0
46.0.0.0/24 is subnetted, 1 subnets
O 46.1.1.0 [110/2] via 34.1.1.4, 09:50:10, GigabitEthernet1/0
R4#sh bgp summary
BGP router identifier 4.4.4.4, local AS number 1234
BGP table version is 9, main routing table version 9
2 network entries using 296 bytes of memory
2 path entries using 128 bytes of memory
2/2 BGP path/bestpath attribute entries using 272 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 744 total bytes of memory
BGP activity 5/3 prefixes, 5/3 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.1.1.1 4 1234 667 663 9 0 0 10:00:07 1
46.1.1.6 4 600 687 696 9 0 0 10:26:26 1
R4#sh bgp summary
BGP router identifier 4.4.4.4, local AS number 1234
BGP table version is 9, main routing table version 9
2 network entries using 296 bytes of memory
2 path entries using 128 bytes of memory
2/2 BGP path/bestpath attribute entries using 272 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 744 total bytes of memory
BGP activity 5/3 prefixes, 5/3 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.1.1.1 4 1234 667 663 9 0 0 10:00:10 1
46.1.1.6 4 600 687 696 9 0 0 10:26:29 1
R4#sh ip bgp
BGP table version is 9, local router ID is 4.4.4.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*>i 5.5.5.5/32 15.1.1.5 0 100 0 500 i
*> 6.6.6.6/32 46.1.1.6 0 0 600 i
R4#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/4] via 34.1.1.3, 10:37:13, GigabitEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/3] via 34.1.1.3, 10:37:13, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 34.1.1.3, 10:37:13, GigabitEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [200/0] via 15.1.1.5, 09:57:06
6.0.0.0/32 is subnetted, 1 subnets
B 6.6.6.6 [20/0] via 46.1.1.6, 10:26:39
12.0.0.0/24 is subnetted, 1 subnets
O 12.1.1.0 [110/3] via 34.1.1.3, 10:37:13, GigabitEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
O 15.1.1.0 [110/4] via 34.1.1.3, 09:57:11, GigabitEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/2] via 34.1.1.3, 10:37:13, GigabitEthernet0/0
34.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 34.1.1.0/24 is directly connected, GigabitEthernet0/0
L 34.1.1.4/32 is directly connected, GigabitEthernet0/0
46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 46.1.1.0/24 is directly connected, GigabitEthernet1/0
L 46.1.1.4/32 is directly connected, GigabitEthernet1/0
R5#sh bgp summary
BGP router identifier 5.5.5.5, local AS number 500
BGP table version is 7, main routing table version 7
2 network entries using 296 bytes of memory
2 path entries using 128 bytes of memory
2/2 BGP path/bestpath attribute entries using 272 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 720 total bytes of memory
BGP activity 4/2 prefixes, 4/2 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
15.1.1.1 4 1234 697 686 7 0 0 10:19:59 1
R5#sh ip bgp
BGP table version is 7, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 5.5.5.5/32 0.0.0.0 0 32768 i
*> 6.6.6.6/32 15.1.1.1 0 1234 600 i
R5#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
6.0.0.0/32 is subnetted, 1 subnets
B 6.6.6.6 [20/0] via 15.1.1.1, 09:50:20
15.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 15.1.1.0/24 is directly connected, GigabitEthernet0/0
L 15.1.1.5/32 is directly connected, GigabitEthernet0/0
R6#sh bgp summary
BGP router identifier 6.6.6.6, local AS number 600
BGP table version is 7, main routing table version 7
2 network entries using 296 bytes of memory
2 path entries using 128 bytes of memory
2/2 BGP path/bestpath attribute entries using 272 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 720 total bytes of memory
BGP activity 4/2 prefixes, 4/2 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
46.1.1.4 4 1234 696 687 7 0 0 10:18:02 1
R6#sh ip bgp
BGP table version is 7, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 5.5.5.5/32 46.1.1.4 0 1234 500 i
*> 6.6.6.6/32 0.0.0.0 0 32768 i
R6#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is not set
5.0.0.0/32 is subnetted, 1 subnets
B 5.5.5.5 [20/0] via 46.1.1.4, 09:49:33
6.0.0.0/32 is subnetted, 1 subnets
C 6.6.6.6 is directly connected, Loopback0
46.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 46.1.1.0/24 is directly connected, GigabitEthernet0/0
L 46.1.1.6/32 is directly connected, GigabitEthernet0/0
测试
在R6上以6.6.6.6为源ping 不通5.5.5.5,由于R2、R3没运行BGP,导致存在路由黑洞。
R6#ping 5.5.5.5 source 6.6.6.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
Packet sent with a source address of 6.6.6.6
.....
Success rate is 0 percent (0/5)