配置BGP的缺省路由

配置BGP 的缺省路由
实验目标
在本实验中,配置 BGP 与两个 Internet 服务提供商( ISP )交换路由信息,如图所示。然后,配置路由过滤来控制发面的 BGP 路由。最后,配置缺省路由,通过使用浮动静态路由来控制哪个 ISP 是首先的,哪个 ISP 的备用的。
步骤1
按图所示,配置好各接口 IP 地址,回环接口表示该 AS 所连接的网络。(略)
步骤2
ISP Client 上配置 BGP 路由协议
ISP1(config)#router bgp 200
ISP1(config-router)#neighbor 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] vi a 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] vi a 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] vi a 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] vi a 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] vi a 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 不可用时,再选择备用路由。
 
 

你可能感兴趣的:(休闲,BGP,缺省路由,备用路由,首选路由)