CCNP系列三十四--- Bgp的本地优先属性

                                              
                           Bgp 的本地优先属性     
                          
Router#config t
Router(config)#host R2
R2(config)#int s1/1
R2(config-if)#ip addr 202.110.101.1 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#clock rate 56000
R2(config-if)#no shut
 
R2(config)#int s1/2
R2(config-if)#ip addr 202.110.104.2 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#no shut
R2(config-if)#exi
R2(config)#router bgp 64500
R2(config-router)#neighbor 202.110.101.2 remote-as 64500
R2(config-router)#neighbor 202.110.104.1 remote-as 64500
R2(config-router)#net 202.110.101.0
R2(config-router)#net 202.110.104.0
 
 
 
 
Router(config)#host R3
R3(config)#int s1/1
R3(config-if)#ip addr 202.110.101.2 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#no shut
R3(config-if)#int s1/2
R3(config-if)#ip addr 202.110.102.1 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#clock rate 56000
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#
 
R3(config)#router bgp 64500
R3(config-router)#neighbor 202.110.101.1 remote-as 64500
R3(config-router)#neighbor 202.110.102.2 remote-as 64501
R3(config-router)#net 202.110.101.0
R3(config-router)#net 202.110.102.0
 
 
config)#
 
R4(config)#int lo0
R4(config-if)#ip addr 192.168.10.1 255.255.255.0
R4(config-if)#exit
R4(config)#int s1/2
R4(config-if)#ip addr 202.110.102.2 255.255.255.0
R4(config-if)#encap hdlc
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#int s1/1
R4(config-if)#ip addr 202.110.103.1 255.255.255.0
R4(config-if)#encap hdlc
R4(config-if)#clock rate 56000
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#router bgp 64501
R4(config-router)#neighbor 202.110.102.1 remote-as 64500
R4(config-router)#neighbor 202.110.103.2 remote-as 64500
R4(config-router)#net 192.168.10.0
R4(config-router)#net 202.110.102.0
R4(config-router)#net 202.110.103.0
 
 
 
Router(config)#host R5
R5(config)#int s1/1
R5(config-if)#ip addr 202.110.103.2 255.255.255.0
R5(config-if)#encap hdlc
R5(config-if)#no shut
R5(config-if)#exit
R5(config)#int
R5(config)#int s1/2
R5(config-if)#ip addr 202.110.104.1 255.255.255.0
              
R5(config-if)#encap hdlc
R5(config-if)#clock rate 56000
R5(config-if)#no shut
R5(config-if)#exit
 
R5(config)#router bgp 64500
R5(config-router)#neighbor 202.110.103.1 remote-as 64501
R5(config-router)#neighbor 202.110.104.2 remote
R5(config-router)#neighbor 202.110.104.2 remote-as 64500
R5(config-router)#net 202.110.103.0
R5(config-router)#net 202.110.104.0                             ^
R5(config-router)#net 202.110.104.0
R5(config-router)#exit
 
 
R2 上测试
 
R2#show ip ro
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
 
C    202.110.101.0/24 is directly connected, Serial1/1
B    192.168.10.0/24 [200/0] via 202.110.102.2, 00:00:20
B    202.110.102.0/24 [200/0] via 202.110.101.2, 00:18:46
B    202.110.103.0/24 [200/0] via 202.110.104.1, 00:13:38
C    202.110.104.0/24 is directly connected, Serial1/2
R2 上的路由,可以看出默认情况下学习 R4 上的路由走 R3, 下面我们将人为通过修改路由器的本地优先属性,使 R2 上学习到 R4 的路由走 R5 ,如果成功,那么今天的目的就基本达到了。本地优先属性的修改语法是:
config-router #bgp  default  local-preference
// 该值默认范围是 0-----4294967295 ,默认是 100 ,且属性值越高越好。
我们让 R3 为默认的 100 ,人为将 R5 的属性值改为 120 ,看试验效果。
 
R5(config)#router bgp 64500
R5(config-router)#bgp default local-preference 120
R5(config-router)#net 202.110.103.0
R5(config-router)#net 202.110.104.0
 
R2 上测试,
 
R2#clear ip ro *
R2#show ip ro
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
 
C    202.110.101.0/24 is directly connected, Serial1/1
B    192.168.10.0/24 [200/0] via 202.110.102.2, 00:00:01  当重新学习路由表后,该路由没有变,不是我们想要的试验结果。
B    202.110.102.0/24 [200/0] via 202.110.101.2, 00:00:01
B    202.110.103.0/24 [200/0] via 202.110.104.1, 00:00:01
C    202.110.104.0/24 is directly connected, Serial1/2
 
 
R2#clear ip bgp *
*Apr 30 20:22:31.027: %BGP-5-ADJCHANGE: neighbor 202.110.101.2 Down User reset
*Apr 30 20:22:31.031: %BGP-5-ADJCHANGE: neighbor 202.110.104.1 Down User reset 提示重新启动。
 
 
R2#show ip bgp
BGP table version is 8, local router ID is 202.110.104.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
* i192.168.10.0     202.110.102.2            0    100      0 64501 i
*>i                 202.110.103.1            0    120      0 64501 I  
> 表示最好路由,优先属性变成了 120
r>i202.110.101.0    202.110.101.2            0    100      0 i
* i202.110.102.0    202.110.101.2            0    100      0 i
*>i                 202.110.103.1            0    120      0 64501 i
* i202.110.103.0    202.110.102.2            0    100      0 64501 i
*>i                 202.110.104.1            0    120      0 i
r>i202.110.104.0    202.110.104.1            0    120      0 i
有这张 bgp 表可以看出明显存在下一跳问题,也可以按照以前的修改下一跳,克服保留下一跳的问题。
分别在 R3 R5 上做,因为理论上 R2 的下一跳应该在这两台路由器上。
 
R3(config)#router bgp 64500
R3(config-router)#neighbor 202.110.101.1 next-hop-self
 
R5(config)#router bgp 64500
R5(config-router)#neighbor 202.110.104.2 next-hop-self
 
 
 
R2#show ip bgp
BGP table version is 12, local router ID is 202.110.104.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
* i192.168.10.0     202.110.101.2            0    100      0 64501 i
*>i                 202.110.104.1            0    120      0 64501 i
*> 202.110.101.0    0.0.0 .0                  0         32768 i
* i                 202.110.101.2            0    100      0 i
* i202.110.102.0    202.110.101.2            0    100      0 i
*>i                 202.110.104.1            0    120      0 64501 i
* i202.110.103.0    202.110.101.2            0    100      0 64501 i
*>i                 202.110.104.1            0    120      0 i
*> 202.110.104.0    0.0.0 .0                  0         32768 i
* i                 202.110.104.1            0    120      0 i
R2#
 
 
 
C    202.110.101.0/24 is directly connected, Serial1/1
B    192.168.10.0/24 [200/0] via 202.110.103.1, 00:01:02 经过的路径也改了过来。
B    202.110.102.0/24 [200/0] via 202.110.103.1, 00:01:02
B    202.110.103.0/24 [200/0] via 202.110.104.1, 00:01:02
C    202.110.104.0/24 is directly connected, Serial1/2
 

你可能感兴趣的:(休闲,BGP,ccnp,本地优先,ccnp实验)