配置BGP的缺省路由<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


实验目标


在本实验中,配置BGP与两个Internet服务提供商(ISP)交换路由信息,如图所示。然后,配置路由过滤来控制发面的BGP路由。最后,配置缺省路由,通过使用浮动静态路由来控制哪个ISP是首先的,哪个ISP的备用的。




BGP active bgp active路由少了_网络


步骤1


按图所示,配置好各接口IP地址,回环接口表示该AS所连接的网络。(略)


步骤2


在ISP和Client上配置BGP路由协议

ISP1(config)#router bgp 200
   
ISP1(config-router)#neighbor <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />10.0.0.2 remote-as 100
   
ISP1(config-router)#network 12.0.1.0 mask 255.255.255.0  //将该路由条目注入到BGP中    
   
    
 
   
ISP2(config)#router bgp 300
   
ISP2(config-router)#neighbor 172.16.0.2 remote-as 100
   
ISP2(config-router)#network 172.16.1.0 mask 255.255.255.0
   
    
 
   
Client(config)#router bgp 100
   
Client(config-router)#neighbor 10.0.0.1 remo
   
Client(config-router)#neighbor 10.0.0.1 remote-as 200
   
Client(config-router)#neighbor 172.16.0.1 remote-as 300
   
Client(config-router)#network 192.168.0.0
   
Client(config-router)#network 192.168.1.0


步骤3


用show ip route检查ISP2的路由表


ISP2#sh ip route
   
    
 
   
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
   
C       172.16.0.0/30 is directly connected, Serial1/1
   
C       172.16.1.0/24 is directly connected, Loopback0
   
B    192.168.0.0/24 [20/0] via 172.16.0.2, 00:03:31
   
     12.0.0.0/24 is subnetted, 1 subnets
   
B       12.0.1.0 [20/0] via 172.16.0.2, 00:03:31    
   
B    192.168.1.0/24 [20/0] via 172.16.0.2, 00:03:31


 


发现ISP2中有一条属于ISP1的路由12.0.1.0。它是由Client通告的一条属于ISP1的路由,ISP2把安安放在它的路由表中。然后ISP2会尝试路由渡越数据流经过Client网络。配置Client路由器使得它只向两个ISP发布192.168.0.0和192.168.1.0。

Client(config)#access-list 1 permit 192.168.0.0 0.0.1.255
   
Client(config)#router bgp 100
   
Client(config-router)#neighbor 10.0.0.1 distribute-list 1 out 
   
Client(config-router)#neighbor 172.16.0.1 distribute-list 1 out
   
Client(config-router)#

再次查看ISP2路由表,去往ISP1的12.0.1.0路由没有出现在表中,而去往ISP2的172.16.1.0网段的路由也不应该出现在ISP1的路由表中


ISP2#sh ip route
   
    
 
   
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
   
C       172.16.0.0/30 is directly connected, Serial1/1
   
C       172.16.1.0/24 is directly connected, Loopback0
   
B    192.168.0.0/24 [20/0] via 172.16.0.2, 00:17:44
   
B    192.168.1.0/24 [20/0] via 172.16.0.2, 00:17:44


 


步骤4


既然和两个ISP的双向通信都已经通过BGP建立了,就需要声明首选路由和备用路由。用以用浮动静态路由或在BGP中实现这一步。


查看Client路由表


Client#sh ip route
   
    
 
   
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
   
C       172.16.0.0/30 is directly connected, Serial1/1
   
B       172.16.1.0/24 [20/0] via 172.16.0.1, 00:23:55
   
     10.0.0.0/30 is subnetted, 1 subnets
   
C       10.0.0.0 is directly connected, Serial1/0
   
C    192.168.0.0/24 is directly connected, Loopback0
   
     12.0.0.0/24 is subnetted, 1 subnets
   
B       12.0.1.0 [20/0] via 10.0.0.1, 00:23:55
   
C    192.168.1.0/24 is directly connected, Loopback1


注意目前还没有定义任何最后求助网关(Gateway of last restore)。这是一个大问题,因为Client是该网络的边界路由器,假设ISP1是主服务提供商而ISP2是备用的服务提供商,配置静态路由如下:

Client(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
   
Client(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220


查看路由表,缺省路由已经被定义


Client#sh ip route
   
Gateway of last resort is 10.0.0.1 to network 0.0.0.0
   
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
   
C       172.16.0.0/30 is directly connected, Serial1/1
   
B       172.16.1.0/24 [20/0] via 172.16.0.1, 00:30:06
   
     10.0.0.0/30 is subnetted, 1 subnets
   
C       10.0.0.0 is directly connected, Serial1/0
   
C    192.168.0.0/24 is directly connected, Loopback0
   
     12.0.0.0/24 is subnetted, 1 subnets
   
B       12.0.1.0 [20/0] via 10.0.0.1, 00:30:06
   
C    192.168.1.0/24 is directly connected, Loopback1
   
S*   0.0.0.0/0 [210/0] via 10.0.0.1    
   
    
 
   
另一个解决方法是使用default-network代替一条0.0.0.0/0的路由。如下先去除前面的浮动静态路由:
   
Client(config)#no ip route 0.0.0.0 0.0.0.0 10.0.0.1 210
   
Client(config)#ino p route 0.0.0.0 0.0.0.0 172.16.0.1 220
   
然后在ISP1上加入一个lo1作为为Client的求助网关,在Client上用default-network配置
   
ISP1(config)#int lo1
   
ISP1(config-if)#ip add 210.210.210.1 255.255.255.0
   
ISP1(config-if)#router bgp 200
   
ISP1(config-router)#network 210.210.210.0
   
    
 
   
Client(config)#ip default-network 210.210.210.0
   
    
 
   
查看路由表
   
Client#sh ip route
   
    
 
   
Gateway of last resort is 10.0.0.1 to network 210.210.210.0
   
    
 
   
B*   210.210.210.0/24 [20/0] via 10.0.0.1, 00:00:47    
   
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
   
C       172.16.0.0/30 is directly connected, Serial1/1
   
B       172.16.1.0/24 [20/0] via 172.16.0.1, 00:36:59
   
     10.0.0.0/30 is subnetted, 1 subnets
   
C       10.0.0.0 is directly connected, Serial1/0
   
C    192.168.0.0/24 is directly connected, Loopback0
   
     12.0.0.0/24 is subnetted, 1 subnets
   
B       12.0.1.0 [20/0] via 10.0.0.1, 00:36:59
   
C    192.168.1.0/24 is directly connected, Loopback1


这样就确定了ISP1作为唯一的缺省路由。你可以通过策略路由选择操探控这条路由,对此,可以通过添加一条到ISP2的主机172.16.0.1的备用路由进行修改


Client(config)#ip route 0.0.0.0 0.0.0.0 172.16.0.1 220


外部网关路由协议(EBGP)所学到路由和管理距离为20,优先于管理距离为220的缺省路由,因为只有当网络210.210.210.0/24不可用时,再选择备用路由。

https://blog.51cto.com/xghe110/89135