隧道解决BGP路由黑洞

来源:互联网 发布:3d max螺丝数据 编辑:程序博客网 时间:2024/04/30 05:10

实验拓扑图:

说明:R1和R2之间建立EBGP邻居关系,R2与R4之间建立IBGP邻居关系同时建立隧道,R4与R5之间建立EBGP邻居关系。IP地址规划和接口如图所示;

要求:通过在R2和R4之间建立隧道使R5能够用源地址5.5.5.5ping通1.1.1.1

 

配置如下:

R1:

interface Loopback0
 ip address 1.1.1.1 255.255.255.255

interface Serial1/2
 ip address 12.12.12.1 255.255.255.0 //基本接口配置

router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255   //通告自己的还回口地址,这里需要注意的是通告的地址必须是自己路由表中有的路由;网络号和掩码必须对应
 neighbor 12.12.12.2 remote-as 200       //和R2建立EBGP邻居关系;这里直接用的接口地址建立邻居关系,如果用还回口建立邻居关系,必须修改为多跳。

R2:

interface Loopback0
 ip address 2.2.2.2 255.255.255.255

interface Serial1/2
 ip address 23.23.23.2 255.255.255.0
   
interface Serial1/3
 ip address 12.12.12.2 255.255.255.0 //基本接口配置

router ospf 100
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 23.23.23.0 0.0.0.255 area 0  //IBGP路由协议,使内部能够互通

interface Tunnel0
 ip address 10.1.1.1 255.255.255.0
 tunnel source Serial1/2
 tunnel destination 34.34.34.4   //创建隧道,指定隧道的IP地址,隧道的源地址,目的地址

router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.1.2 remote-as 200 //和R4建立IBGP邻居关系,这里10.1.1.2为R4tunnel口的IP地址,通过这条命令从R4学过来的BGP路由的下一跳为10.1.1.2,这样就可以确保到5.5.5.5的数据包从tunnel口发送出去,这里是关键。
 neighbor 10.1.1.2 next-hop-self  //指定更新源为自己,不然学到的BGP路由不会放进路由表
 neighbor 12.12.12.1 remote-as 100  //和R1建立EBGP邻居关系

R3:

interface Loopback0
 ip address 3.3.3.3 255.255.255.255

interface Serial1/2
 ip address 34.34.34.3 255.255.255.0
 serial restart-delay 0
!        
interface Serial1/3
 ip address 23.23.23.3 255.255.255.0  //基本接口配置

router ospf 100
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 23.23.23.0 0.0.0.255 area 0
 network 34.34.34.0 0.0.0.255 area 0   //内部路由协议配置

 

R4:

interface Loopback0
 ip address 4.4.4.4 255.255.255.255

interface Serial1/2
 ip address 45.45.45.4 255.255.255.0
interface Serial1/3
 ip address 34.34.34.4 255.255.255.0   //基本接口配置

router ospf 100
 log-adjacency-changes
 network 4.4.4.4 0.0.0.0 area 0
 network 34.34.34.0 0.0.0.255 area 0  //内部路由协议配置

interface Tunnel0
 ip address 10.1.1.2 255.255.255.0
 tunnel source Serial1/3
 tunnel destination 23.23.23.2   //建立隧道

router bgp 200
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.1.1 remote-as 200   //和R2建立IBGP邻居关系,注意用对方的tunnel口
 neighbor 10.1.1.1 next-hop-self
 neighbor 45.45.45.5 remote-as 300  //和R5建立EBGP邻居关系

R5:

interface Loopback0
 ip address 5.5.5.5 255.255.255.255
interface Serial1/3
 ip address 45.45.45.5 255.255.255.0  //基本接口配置

router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 5.5.5.5 mask 255.255.255.255
 neighbor 45.45.45.4 remote-as 200

 

测试:

R5#ping 1.1.1.1 source 5.5.5.5

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 5.5.5.5
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 116/164/260 ms
R5#

 


 

 

原创粉丝点击