系列文章
实验拓扑
实验要求
所有路由器都配置BGP协议使R3和R4能收到R1的环回口地址的路由条目。
IP地址表
路由器 | 接口 | IP地址 |
---|---|---|
R1 | f0/0 | 192.168.1.1 |
R2 | f1/0 | 192.168.1.2 |
R2 | f0/0 | 192.168.2.1 |
R3 | f1/0 | 192.168.2.2 |
R3 | f0/0 | 192.168.3.1 |
R4 | f1/0 | 192.168.3.2 |
R1 | loopback0 | 1.1.1.1 |
实验配置
配置R1
R1#configure terminal
R1(config)#interface f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface loopback0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#router bgp 100 //配置BGP协议
R1(config-router)#neighbor 192.168.1.2 remote-as 200 //指定EBGP邻居并标明邻居所在的BGP进程
R1(config-router)#neighbor 192.168.1.2 ebgp-multihop 5 //指定EBGP邻居关系可以传递5跳
R1(config-router)#network 1.1.1.0 mask 255.255.255.0 //宣告需要传递的路由条目并指定子网掩码
R1(config-router)#end
配置R2
R2#configure terminal
R2(config)#interface f1/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface f0/0
R2(config-if)#ip address 192.168.2.1 255.255.255.0
R2(config-if)#no shutdown
R2(config)#router bgp 200 //配置BGP协议
R2(config-router)#neighbor 192.168.1.1 remote-as 100 //指定EBGP邻居并标明邻居所在的BGP进程
R2(config-router)#neighbor 192.168.1.1 ebgp-multihop 5 //指定EBGP邻居关系可以传递5跳
R2(config-router)#neighbor 192.168.2.2 remote-as 200 //指定IBGP邻居并标明邻居所在的BGP进程
R2(config-router)#neighbor 192.168.2.2 next-hop-self //通告192.168.2.2地址其下一跳为R2,需要通过R2来和EBGP传递路由条目
R2(config-router)#neighbor 192.168.3.2 next-hop-self
R2(config-router)#exit
R2(config)#ip route 192.168.3.2 255.255.255.255 192.168.2.2
R2(config)#router bgp 200
R2(config-router)#neighbor 192.168.3.2 remote-as 200 此处需要直接指定R4的地址,因为IBGP只传递一跳,若指到R3的地址,R4将接收不到路由条目
R2(config-router)#end
配置R3
R3#configure terminal
R3(config)#interface f1/0
R3(config-if)#ip address 192.168.2.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface f0/0
R3(config-if)#ip address 192.168.3.1 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#router bgp 200
R3(config-router)#neighbor 192.168.2.1 remote-as 200
配置R4
R4#configure terminal
R4(config)#interface f1/0
R4(config-if)#ip address 192.168.3.2 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#ip route 192.168.2.1 255.255.255.255 192.168.3.1
R4(config)#router bgp 200
R4(config-router)#neighbor 192.168.2.1 remote-as 200
R4(config-router)#end
接下来
通过:show ip route ------+查看路由表,R3、R4会收到来自R1环回口的BGP协议路由条目。
R3:
R3#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
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [200/0] via 192.168.2.1, 00:21:01
C 192.168.2.0/24 is directly connected, FastEthernet1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
R4:
R4#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
1.0.0.0/24 is subnetted, 1 subnets
B 1.1.1.0 [200/0] via 192.168.2.1, 00:05:18
192.168.2.0/32 is subnetted, 1 subnets
S 192.168.2.1 [1/0] via 192.168.3.1
C 192.168.3.0/24 is directly connected, FastEthernet1/0
实验总结
配置EBGP协议首先需要保证底层互通,通过neighbor命令来传递路由条目并且在EBGP中需要配置多跳命令。