您的位置:首页 > 运维架构

利用Loopback建立BGP邻居

2013-03-21 12:57 465 查看
[align=center]利用[/b]Loopback[/b]建立[/b]BGP[/b]邻居[/b][/b][/align]



如何确保路由器的源地址是稳定、一致不变?一般情况下我们使用Loopback地址。

在路由器上配置了Loopback地址后,当路由器之间的链路Down掉了,那他们的邻居关系依然保持,因为源地址没变。
一般要求路由器与邻居之间至少有一条路径是可用的。这样邻居关系就不会出现问题。

实验目的:通过使用Loopback口建立邻居关系,实现172.16.1.0&192.168.1.0网段互相访问

========AS 123中先运行一个IGP协议(这里以EIGRP为例)========
R2(config)#router eigrp 90
R2(config-router)#no au
R2(config-router)#net 12.1.1.2 0.0.0.0
R2(config-router)#net 2.2.2.2 0.0.0.0

R1(config)#router ei 90
R1(config-router)#no au
R1(config-router)#net 12.1.1.1 0.0.0.0
R1(config-router)#net 13.1.1.1 0.0.0.0
R1(config-router)#net 1.1.1.1 0.0.0.0

R3(config)#router eigrp 90
R3(config-router)#no au
R3(config-router)#net 13.1.1.3 0.0.0.0
R3(config-router)#net 3.3.3.3 0.0.0.0

=====R1、R2利用loopback建立IBGP邻居关系=============
R2(config)#router bgp 123
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 1.1.1.1 remote-as 123
R2(config-router)#neighbor 1.1.1.1 update-source[/u] loopback 0
[align=left]//在BGP建邻居过程中,neighbor命令所指定的邻居的IP地址,也必须是邻居用来和本路由器建立TCP连接的地址。如果不匹配,两端建立不起邻居关系。可以在路由器上用这个命令指定使用哪个接口来和邻居建立联系,这个接口就是自已的更新源[/align]

R1(config)#router bgp 123
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#nei 2.2.2.2 remote-as 123
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0

=====R1、R3利用loopback建立IBGP邻居关系=============
R3(config)#router bgp 123
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 1.1.1.1 remote-as 123
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0

R1(config)#router bgp 123
R1(config-router)#neighbor 3.3.3.3 remote-as 123
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0

=====R2、R3利用loopback建立IBGP邻居关系=============
R2(config)#router bgp 123
R2(config-router)#neighbor 3.3.3.3 remote-as 123
R2(config-router)#neighbor 3.3.3.3 update-source loopback 0

R3(config)#router bgp 123
R3(config-router)#neighbor 2.2.2.2 remote-as 123
R3(config-router)#neighbor 2.2.2.2 update-source loopback 0

=======R2、R4建立EBGP邻居关系=========
R4(config)#router bgp 4
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 2.2.2.2 remote-as 123
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
//在EBGP中使用Loopback端口,需要使用命令Neighbor ip ebgp-multihop x,X为跳数。这个命令只能使用在EBGP情况下。BGP中Next-hop(下一跳)不是指下一个路由器,而是指到达目标网络的下一个AS。

R4(config)#ip route 2.2.2.0 255.255.255.0 24.1.1.2
//要有正确的去往对方loopback口的路由才能正常的建立邻居关系

R2(config-router)#neighbor 4.4.4.4 remote-as 4
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#neighbor 4.4.4.4 ebgp-multihop 2
R2(config)#ip route 4.4.4.0 255.255.255.0 24.1.1.4

=======R3、R5建立EBGP邻居关系=========
R5(config)#router bgp 5
R5(config-router)#bgp router-id 5.5.5.5
R5(config-router)#neighbor 3.3.3.3 remote-as 123
R5(config-router)#neighbor 3.3.3.3 update-source loopback 0
R5(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R5(config)#ip route 3.3.3.0 255.255.255.0 35.1.1.3

R3(config-router)#neighbor 5.5.5.5 remote-as 5
R3(config-router)#neighbor 5.5.5.5 update-source loopback 0
R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2
R3(config)#ip route 5.5.5.0 255.255.255.0 35.1.1.5

===========检查各路由器的邻居关系=============
R4#sh ip bgp sum
BGP router identifier 4.4.4.4, local AS number 4
BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 123 8 9 1 0 0 00:05:09 0

R2(config)#do sh ip bgp sum
BGP router identifier 2.2.2.2, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
1.1.1.1 4 123 13 13 1 0 0 00:10:42 0
3.3.3.3 4 123 8 8 1 0 0 00:04:59 0
4.4.4.4 4 4 4 4 1 0 0 00:00:48 0

R1#sh ip bgp sum
BGP router identifier 1.1.1.1, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 123 18 17 1 0 0 00:14:26 0
3.3.3.3 4 123 15 14 1 0 0 00:10:49 0

R3#sh ip bgp sum
BGP router identifier 3.3.3.3, local AS number 123
BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
1.1.1.1 4 123 14 15 1 0 0 00:11:29 0
2.2.2.2 4 123 13 13 1 0 0 00:09:37 0
5.5.5.5 4 5 7 6 1 0 0 00:02:46 0

R5#sh ip bgp sum
BGP router identifier 5.5.5.5, local AS number 5
BGP table version is 1, main routing table version 1

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.3.3.3 4 123 7 7 1 0 0 00:03:57 0

======在R4,R5上各起一个网段,实现互访==========
R4(config)#inter lo 1
R4(config-if)#ip add 172.16.1.1 255.255.255.0

R5(config)#inter lo 1
R5(config-if)#ip add 192.168.1.1 255.255.255.0

R4(config-if)#router bgp 4
R4(config-router)#network 172.16.1.0 mask 255.255.255.0

R5(config-if)#router bgp 5
R5(config-router)#network 192.168.1.0 mask 255.255.255.0

R2(config)#router bgp 123
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#neighbor 3.3.3.3 next-hop-self

R3(config)#router bgp 123
R3(config-router)#neighbor 1.1.1.1 next-hop-self
R3(config-router)#neighbor 2.2.2.2 next-hop-self

=========测试172.16.1.0&192.168.1.0网络互访=====
R4#p 192.168.1.1 sou 172.16.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
Packet sent with a source address of 172.16.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 528/948/1204 ms

R5#ping 172.16.1.1 source 192.168.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 776/1082/1200 ms

本文出自 “老胳膊BLOG” 博客,请务必保留此出处http://laogebo.blog.51cto.com/413916/101902
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  BGP Loopback