
R1#conf t
R1(config)#inter f0/0
R1(config-if)#ip add 192.34.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router bgp 1
R1(config-router)#neighbor 192.34.1.2 remote-as 2 //创建BGP邻居
R2#conf t
R2(config)#inter f0/0
R2(config-if)#ip add 192.34.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#inter f0/1
R2(config-if)#ip add 192.34.2.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router bgp 2
R2(config-router)#neighbor 192.34.1.1 remote-as 1 //创建BGP邻居
R2(config-router)#neighbor 192.34.2.2 remote-as 2 //创建BGP邻居
R3#conf t
R3(config)#inter f0/1
R3(config-if)#ip add 192.34.2.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#inter f0/0
R3(config-if)#ip add 192.34.3.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#router bgp 2
R3(config-router)#neighbor 192.34.2.1 remote-as 2 //创建BGP邻居
R3(config-router)#neighbor 192.34.3.2 remote-as 3 //创建BGP邻居
R4#conf t
R4(config)#inter f0/0
R4(config-if)#ip add 192.34.3.2 255.255.255.0
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#inter loop 0
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#router bgp 3
R4(config-router)#neighbor 192.34.3.1 remote-as 2 //创建邻居关系
R4(config-router)#network 34.34.1.0 mask 255.255.255.0 //通告Loop 0网段到BGP
查看R1的BGP信息和路由表
R1#show ip bgp
R1#show ip route
Codes: 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
Gateway of last resort is not set
C 192.34.1.0/24 is directly connected, FastEthernet0/0
R1#
有没有发现没有任何BGP信息?路由表也没有学到,下面给R2和R3配置RIP内部网关协议。
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 192.34.2.0
R2(config-router)#no auto-summary
R2(config-router)#network 192.34.1.0
R3(config)#router rip
R3(config-router)#version 2
R3(config-router)#network 192.34.2.0
R3(config-router)#no auto-summary
R3(config-router)#network 192.34.3.0
查看R1的BGP信息和路由表
R1#show ip bgp
BGP table version is 2, local router ID is 192.34.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 34.34.1.0/24 192.34.1.2 0 2 3 i
R1#show ip route
Codes: 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
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
B 34.34.1.0 [20/0] via 192.34.1.2, 00:04:23
C 192.34.1.0/24 is directly connected, FastEthernet0/0
R1#
此时的R1已经通过BGP3 -> BGP2 的路线学习到了R4的Loop 0网段信息,同时也学习到了路由表。