CCNP-33 BGP 3

简介:

CCNP-33 BGP 3

实验拓扑:

实验要求:按照拓扑图将三台路由器分别放置在 AS 100/200/300 中,首先配置 R1 R2 R3 成为 EBGP PEER ,观察 BGP 路由表中的 AS PATH 属性,然后再将 R2 R3 也配置为 EBGP PEER ,再观察 BGP 路由表中的 AS PATH 属性,看看有什么变化。
试验目的:掌握 AS PATH 属性在 BGP 路由选择中的作用。

试验配置:
R1
R1(config)#int f0/0
R1(config-if)#ip add 192.1.1.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int loop0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#router bgp 100
R1(config-router)#nei
R1(config-router)#neighbor 192.1.1.2 remote-as 200
R1(config-router)#network 10.1.1.0 mask 255.255.255.0
R1(config-router)#exit
 
R2
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int f1/0
R2(config-if)#ip add 193.1.1.1 255.255.255.0
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int loop0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#router bgp 200
R2(config-router)#neighbor 192.1.1.1 remote-as 100
R2(config-router)#neighbor 193.1.1.2 remote-as 300
R2(config-router)#network 192.1.1.0
R2(config-router)#network 193.1.1.0
R2(config-router)#exit
 
R3
R3(config)#int f1/0
R3(config-if)#ip add 193.1.1.2 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int loop0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#exit
R3(config)#router bgp 300
R3(config-router)#neighbor 193.1.1.1 remote-as 200
R3(config-router)#exit
好了,配置完成,然后我们在 R3 上查看 BGP 路由表:
R3#show ip bgp
BGP table version is 5, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      193.1.1.1                              0 200 100 i
*> 192.1.1.0        193.1.1.1                0             0 200 i
r> 193.1.1.0        193.1.1.1                0             0 200 i
观察第一行我们发现在 Path 这一列有 200 100 的标示,说明学习这条路由的路径是        AS 100----AS 200----AS 300
通过 AS PATH 属性,明白的表示出一条路由传播路径,这也是 BGP 预防环路发生的一种
法,如果发现传播过来的路由的 AS PATH 属性里面列出了本地的 AS 号,路由器就认为这条路由已经学习过了,并且形成了一个环,然后这条路由信息将被丢弃。
上面第三行有 ”r” 标志的路由信息说明这条路又没有被写入路由表,原因可以通过命令
show ip bgp rib-failure 来查看:
R3#show ip bgp rib-failure
Network            Next Hop                      RIB-failure   RIB-NH Matches
193.1.1.0          193.1.1.1           Higher admin distance              n/a
 
Higher admin distance 表示较高的管理距离,因为 193.1.1.0 这个网段是直连网段,管理距离为 0 ,而 EBGP 的管理距离为 20 ,在路由表选择写入的路由的时候如果有两种路由协议都有到达某个网段的信息,那么选择管理距离较低的写入路由表,这里是将直连路由写入了路由表, 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
 
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
B       10.1.1.0 [20/0] via 193.1.1.1, 00:02:02
C    193.1.1.0/24 is directly connected, FastEthernet1/0
B    192.1.1.0/24 [20/0] via 193.1.1.1, 00:00:59
有两条以 B 表示的路由,这表示是从 BGP 学习到的,我们可以 ping 测试一下:
R3#p 10.1.1.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/182/276 ms
好的,通了。
下面我们配置 R1,R3 ,使之也成为 EBGP PEER
R1(config)#int f1/0
R1(config-if)#ip add 194.1.1.1 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#router bgp 100
R1(config-router)#neighbor 194.1.1.2 remote-as 300
R1(config-router)#exit
 
R3(config)#int f0/0
R3(config-if)#ip add 194.1.1.2 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#router bgp 300
R3(config-router)#neighbor 194.1.1.1 remote-as 100
R3(config-router)#exit
好了,我们 clear ip bgp * 强制重起一下 BGP 进程,再观察 R3 上的 BGP 路由表:
R3#show ip bgp
BGP table version is 6, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      194.1.1.1                0             0 100 i
*                   193.1.1.1                              0 200 100 i
*  192.1.1.0        194.1.1.1                              0 100 200 i
*>                  193.1.1.1                0             0 200 i
r  193.1.1.0        194.1.1.1                              0 100 200 i
r>                  193.1.1.1                0             0 200 i
看到变化了吧!我们来逐条进行分析:
*> 10.1.1.0/24      194.1.1.1                0             0 100 i
*                   193.1.1.1                              0 200 100 i
首先看前两行都是到 10.1.1 .0/24 的路由,但是最佳路由是从 194.1.1.1 学到的,因为它的 AS PATH 只经过 AS 100 这一个自治系统,但是从 193.1.1.1 学到的要经过 AS 100/200 两个自治系统,也就是说 BGP 在选路的时候选择经过的 AS 最少的那条路由作为最佳路由;
*  192.1.1.0        194.1.1.1                              0 100 200 i
*>                  193.1.1.1                0             0 200 i
然后再来比较这两条路由,同样都是到达 192.1.1.0 的路由,也同样是选择了 AS PATH 最少的作为最佳路由写入路由表;
r  193.1.1.0        194.1.1.1                              0 100 200 i
r>                  193.1.1.1                0             0 200 i
最后的这两条都是标记了 r 的,也就是没有写入路由表,是因为 193.1.1.0 这个网段是自己直连的网段,不管从哪个 AS 中学到的,因为管理距离的原因,都会将直连路由写入路由表,放弃从 BGP 学到的相同网段的路由。
我们再来看一下 R1 BGP 路由表和 IP 路由表:
R1#show ip bgp
BGP table version is 5, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
r  192.1.1.0        194.1.1.2                              0 300 200 i
r>                  192.1.1.2                0             0 200 i
*  193.1.1.0        194.1.1.2                              0 300 200 i
*>                  192.1.1.2                0             0 200 i
 
R1#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
C       1.1.1.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Loopback1
B    193.1.1.0/24 [20/0] via 192.1.1.2, 00:37:21
C    192.1.1.0/24 is directly connected, FastEthernet0/0
C    194.1.1.0/24 is directly connected, FastEthernet1/0
我们只看最后到 193.1.1.0 这个网段的路由,下一条属性为 192.1.1.2 ,这是因为我们向 BGP 通告 193.1.1.0 这个网段是在 R2 上做的,如果我们取消这条路由在 R2 上的通告,而在 R3 上通告这条路由的话, R1 BGP 路由表和 IP 路由表又会是什么样子的呢?
我们可以根据 BGP 选路的特点来假想一下,如果在 R3 上通告 193.1.1.0/24 这条路由的话,那么 R1 BGP 路由表有关这条路由的下一跳属性将会变为 194.1.1.2 AS PATH 属性 AS 300 ,并且路由表也将随之变化,还有 R2 上的 BGP 路由表也将发生变化,会有一条到 193.1.1.0 被标记为 ”r” 的路由, AS PATH 属性为 AS 300 我们可以来做一下试验,验证一下我们的猜测是否正确:
作更改前 R2 BGP 路由表:
R2#show ip bgp
BGP table version is 4, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      192.1.1.1                0             0 100 i
*> 192.1.1.0        0.0.0.0                  0         32768 i
*> 193.1.1.0        0.0.0.0                  0         32768 i
193.1.1.0 是自己产生的路由,然后开始更改 R2 R3 的配置:
R1#show ip bgp
BGP table version is 8, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
r  192.1.1.0        194.1.1.2                              0 300 200 i
r>                  192.1.1.2                0             0 200 i
*  193.1.1.0        192.1.1.2                              0 200 300 i
*>                  194.1.1.2                0             0 300 i
以上为 R1 BGP 路由表;
R1#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
C       1.1.1.0 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Loopback1
B    193.1.1.0/24 [20/0] via 194.1.1.2, 00:04:59
C    192.1.1.0/24 is directly connected, FastEthernet0/0
C    194.1.1.0/24 is directly connected, FastEthernet1/0
以上为 R1 的路由表;
R2#show ip bgp
BGP table version is 5, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*  10.1.1.0/24      193.1.1.2                              0 300 100 i
*>                  192.1.1.1                0             0 100 i
*> 192.1.1.0        0.0.0.0                  0         32768 i
r> 193.1.1.0        193.1.1.2                0             0 300 i
r                   192.1.1.1                              0 100 300 i
以上为 R2 BGP 路由表。
上面的输出显示和我们根据 BGP 选路的条件推断出来的是一样的。

实验总结:掌握 AS PATH 属性在 BGP 路由选择时的作用。



























本文转自loveme2351CTO博客,原文链接: http://blog.51cto.com/loveme23/54224  ,如需转载请自行联系原作者


相关文章
|
负载均衡 算法 网络架构
|
网络协议 网络架构
|
网络协议 网络架构
|
网络协议 网络架构
|
网络协议 网络架构
|
网络协议 网络架构 iOS开发