配置BGP本地优先级


一、拓扑图:

 
配置BGP本地优先级
 
二、配置基本的BGP。以R1为例:
R1(config)#router bgp 64512
R1(config-router)#net 172.16.1.0 mask 255.255.255.0
R1(config-router)#net 192.168.2.0         
R1(config-router)#net 130.130.1.0 mask 255.255.255.0
R1(config-router)#nei 172.16.1.2 remote 64512
R1(config-router)#nei 192.168.2.1 remote 64513
 
三、分析选择的下一跳:
1
、查看一下R3R4的路由表:
R3#sh ip route
………………
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.1.1, 00:02:55
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/1
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/0] via 192.168.1.1, 00:00:13  R3130.130.1.1通过192.168.1.1走)
C    192.168.1.0/24 is directly connected, Serial1/0
B    192.168.2.0/24 [200/0] via 10.1.1.2, 00:02:59
 
R4#sh ip route
………………
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [20/0] via 192.168.2.2, 00:03:57
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/0
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [20/0] via 192.168.2.2, 00:00:56 R4130.130.1.0通过192.168.2.2走)
B    192.168.1.0/24 [200/0] via 10.1.1.1, 00:03:57
C    192.168.2.0/24 is directly connected, FastEthernet0/0
 
2、查看一下R3R4130.130.1.1/24BGP最佳路径:
 
R3#sh ip bgp
BGP table version is 9, local router ID is 192.168.1.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
* i10.1.1.0/24      10.1.1.2                 0    100      0 i
*>                  0.0.0.0                  0         32768 i
*> 130.130.1.0/24   192.168.1.1                            0 64512 i
* i                 192.168.2.2              0    100      0 64512 i
* i172.16.1.0/24    192.168.2.2              0    100      0 64512 i
*>                  192.168.1.1              0             0 64512 i
*  192.168.1.0      192.168.1.1              0             0 64512 i
*>                  0.0.0.0                  0         32768 i
*>i192.168.2.0      10.1.1.2                 0    100      0 i
*                   192.168.1.1                            0 64512 i
 
R4#sh ip bgp
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
* i                 10.1.1.1                 0    100      0 i
i130.130.1.0/24   192.168.1.1              0    100      0 64512 i
*>                  192.168.2.2              0             0 64512 i
* i172.16.1.0/24    192.168.1.1              0    100      0 64512 i
*>                  192.168.2.2              0             0 64512 i
*  192.168.1.0      192.168.2.2                            0 64512 i
*>i                 10.1.1.1                 0    100      0 i
*> 192.168.2.0      0.0.0.0                  0         32768 i
*                   192.168.2.2              0             0 64512 i
R4#
 
四、理论上来讲BGP选择了自己认为的最佳路径,但我们从图中拓扑可以看到:R4àR1是快速以太网都是为100M的链路。而R3通过的链路却要通过两条串口链路。如果串口链路的带宽比较小,那么这样的选择是不合理的。R3选择了一个次路由。比较R3R4BGP数据库。我们应该通过什么样的方式来改变R3的选择路径呢?首先我们要了解一个概念:BGP在选择最佳路由时,并不会考虑具体链路的带宽。从上图可以看到,显示的本地优先级都为100。根据这种判断,我们可以在本地配置本地优先级来确定数据流如何流出本自治系统。
1
、把R4的优先级提高,因为BGP会优先选择本地优先级值较高的路由。
 
R4(config)#router bgp 64513
R4(config-router)#bgp default local-preference 150  (配置一个高出50的优先级)
 
2clear ip bgp * soft 软涮新一下,再来看一下R3的路由表和BGP数据库:
R3#sh ip route
 
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [200/0] via 192.168.2.2, 00:01:09
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/1
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [200/0] via 192.168.2.2, 00:01:09 (现在下一跳变为:192.168.2.2
C    192.168.1.0/24 is directly connected, Serial1/0
B    192.168.2.0/24 [200/0] via 10.1.1.2, 00:58:57
 
R3#sh ip bgp 
 
   Network          Next Hop            Metric LocPrf Weight Path
* i10.1.1.0/24      10.1.1.2                 0    150      0 i
*>                  0.0.0.0                  0         32768 i
*  130.130.1.0/24   192.168.1.1                            0 64512 i
*>i                 192.168.2.2              0    150      0 64512 i (最佳路径为192.168.2.2)
*>i172.16.1.0/24    192.168.2.2              0    150      0 64512 i
*                   192.168.1.1              0             0 64512 i
* i192.168.1.0      192.168.2.2              0    150      0 64512 i
*                   192.168.1.1              0             0 64512 i
*>                  0.0.0.0                  0         32768 i
*>i192.168.2.0      10.1.1.2                 0    150      0 i
*                   192.168.1.1                            0 64512 i
R3#
五、下一跳自我:由EBGP学来的路由信息,在传递给IBGP邻居时,不改变其下一跳属性值 。(R1学习到的130.130.1.0这条路由传递给IBGP整个AS64513时不改变其下一跳属性,也就是都为192.168.2.2
1
为了能够在R3上能看到路由变化,可以在R4上指定下一跳为自己,配置通告给R3的路由:
R4(config)#router bgp 64513
R4(config-router)#nei 10.1.1.1 next-hop-self
2、再来看一下R3的路由表和拓扑数据:
R3#sh ip route
………………
     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.1.0 [200/0] via 10.1.1.2, 00:01:32
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/1
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [200/0] via 10.1.1.2, 00:01:32
C    192.168.1.0/24 is directly connected, Serial1/0
B    192.168.2.0/24 [200/0] via 10.1.1.2, 01:47:43

R3#sh ip bgp 
 
   Network          Next Hop            Metric LocPrf Weight Path
* i10.1.1.0/24      10.1.1.2                 0    150      0 i
*>                  0.0.0.0                  0         32768 i
*  130.130.1.0/24   192.168.1.1                            0 64512 i
*>i                 10.1.1.2                 0    150      0 64512 i
*>i172.16.1.0/24    10.1.1.2                 0    150      0 64512 i
*                   192.168.1.1              0             0 64512 i
* i192.168.1.0      10.1.1.2                 0    150      0 64512 i
*                   192.168.1.1              0             0 64512 i
*>                  0.0.0.0                  0         32768 i
*>i192.168.2.0      10.1.1.2                 0    150      0 i
*                   192.168.1.1                            0 64512 i
 
 
六:终于完成了。前天配置的时候,本地优先级不能显示出来。很郁闷的是网上也找不到合适的显示本地优级资料。于是放下了,今天弄出来了。现在想想:可能是模拟器的问题。今天是同样的配置,然后到R3和R4上show 都能显示出来各自的本地优先级。要说明一下:只有两条或多条路径可选择的情况下才会显示出本地优先级。只有一条路径可选的话,不会显示出本地优先级
上一篇:centos 8.2中安装go 1.7


下一篇:HttpServletRequest