BGP 管理距離修改及分析

    所謂管理距離(AD)就是指一種路由協議的可信度,對於多種不一樣的路由協議到同一個目的地的路由信息,路由器首先根據管理距離的大小決定相信哪個路由協議。管理距離只用於多種協議的狀況下會使用,同一路由協議中,選路按照該路由協議的選路機制,而不會用管理距離來選路。管理距離越小,其優先級越高,可信度越高。ide

wKiom1SWzaiiQYJdAAFXSXDGu7w866.jpg

如上圖,在R6上查看BGP路由表spa

R6#show ip route bgprouter

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGPxml

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter areablog

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2ip

       E1 - OSPF external type 1,E2 - OSPF external type 2路由

       i - IS-IS, su - IS-ISsummary, L1 - IS-IS level-1, L2 - IS-IS level-2get

       ia - IS-IS inter area, * -candidate default, U - per-user static routeit

       o - ODR, P - periodicdownloaded static route, H - NHRP, l - LISPio

       + - replicated route, % -next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1subnets

B        4.4.4.4 [200/0] via 2.2.2.2, 00:00:06

      5.0.0.0/32 is subnetted, 1subnets

B        5.5.5.5 [20/0] via 56.1.1.1, 00:03:51

B     192.168.10.0/24 [200/0] via 2.2.2.2, 00:00:06

B     192.168.11.0/24 [200/0] via 2.2.2.2, 00:00:06

B     192.168.12.0/24 [200/0] via 2.2.2.2, 00:00:06

   從上述可知,從IBGP鄰居R2收到的路由,其管理距離爲200,從EBGP鄰居R5收到的路由,其管理距離爲20。

   小結:iBGP的管理距離爲200EBGP的管理距離爲20BGP的本地(LocalAD默認等同於IBGP,本地路由指經過network命令獲得。


現經過distance命令修改從IBGP過來的路由管理距離爲150

R6(config)#router bgp 65414

R6(config-router)#distance150 2.2.2.2 0.0.0.0  //修改來至鄰居2.2.2.2的管理距離

配置完成後,清鄰居關係(須要硬清,軟清不起做用,沒法觀查效果)後,可查看BGP路由狀況

R6#clear ip bgp *

R6#show ip route bgp

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGP

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1,E2 - OSPF external type 2

       i - IS-IS, su - IS-ISsummary, 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 - periodicdownloaded static route, H - NHRP, l - LISP

       + - replicated route, % -next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1subnets

B        4.4.4.4 [150/0] via 2.2.2.2, 00:00:46

      5.0.0.0/32 is subnetted, 1subnets

B        5.5.5.5 [20/0] via 56.1.1.1,00:00:46

B     192.168.10.0/24 [150/0] via 2.2.2.2, 00:00:46

B     192.168.11.0/24 [150/0] via 2.2.2.2, 00:00:46

B     192.168.12.0/24 [150/0] via 2.2.2.2, 00:00:46

除了指定鄰居修改全部的路由,還能夠指定相應鄰居,後面跟ACL,匹配須要修改的路由的管理距離;

現配置一個ACL,匹配4.4.4.4/32的路由,修改其管理距離爲120,修改來至R55.5.5.5/32的管理距離爲50,其它的管理距離爲默認;

R6(config)#access-list 10 permit 4.4.4.4 0.0.0.0
R6(config)#router bgp 65414
R6(config-router)#distance 150 2.2.2.2 0.0.0.0 10
R6(config-router)#distance 50 56.1.1.1 0.0.0.0

R6#clear ip bgp *  //硬清,軟清看不見效果

R6#show ip route bgp

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGP

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1,E2 - OSPF external type 2

       i - IS-IS, su - IS-ISsummary, 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 - periodicdownloaded static route, H - NHRP, l - LISP

       + - replicated route, % -next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1subnets

B        4.4.4.4 [150/0] via 2.2.2.2, 00:00:16

      5.0.0.0/32 is subnetted, 1subnets

B        5.5.5.5 [50/0] via 56.1.1.1, 00:00:16

B     192.168.10.0/24 [200/0] via 2.2.2.2,00:00:16

B     192.168.11.0/24 [200/0] via 2.2.2.2,00:00:16

B     192.168.12.0/24 [200/0] via 2.2.2.2,00:00:16

從上看出,來至R24.4.4.4/32路由的管理距離爲150,來至R55.5.5.5/32路由的管理距離爲50,其它的爲默認的200

如今在R5R2上分別查看BGP的路由狀況;

R5#show ip route bgp

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGP

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1,E2 - OSPF external type 2

       i - IS-IS, su - IS-ISsummary, 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 - periodicdownloaded static route, H - NHRP, l - LISP

       + - replicated route, % -next hop override

Gateway of last resort is not set

      1.0.0.0/32 is subnetted, 1subnets

B        1.1.1.1 [20/0] via56.1.1.2, 00:00:25

      2.0.0.0/32 is subnetted, 1subnets

B        2.2.2.2 [20/0] via56.1.1.2, 00:00:25

      3.0.0.0/32 is subnetted, 1subnets

B        3.3.3.3 [20/0] via56.1.1.2, 00:00:25

B     192.168.10.0/24 [20/0] via56.1.1.2, 00:00:25

B     192.168.11.0/24 [20/0] via56.1.1.2, 00:00:25

B     192.168.12.0/24 [20/0] via56.1.1.2, 00:00:25

R2#show ip route bgp

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGP

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1,E2 - OSPF external type 2

       i - IS-IS, su - IS-ISsummary, 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 downloadedstatic route, H - NHRP, l - LISP

       + - replicated route, % -next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1subnets

B        4.4.4.4 [200/0] via3.3.3.3, 00:27:30

      5.0.0.0/32 is subnetted, 1subnets

B        5.5.5.5 [200/0] via 6.6.6.6, 00:00:34

B     192.168.10.0/24 [200/0] via3.3.3.3, 00:27:30

B     192.168.11.0/24 [200/0] via3.3.3.3, 00:27:30

B     192.168.12.0/24 [200/0] via3.3.3.3, 00:27:30

    從上可看出,R2R5上的路由條目的管理距離爲默認值,並無因R6修改了管理距離而改變;

   小結:管理距離只具備本地有意義,不可傳遞給對等體鄰居(包括EBGPIBGP


現使用命令distance X Y Z

X爲外部路由Distance for routes external to the AS

Y爲內部路由Distance for routes internal to the AS

Z爲本地路由Distance for local routes(包括network和聚合路由)


現配置如下命令後,將外部的管理距離設置爲120,內部的設置爲150,本地的爲111

R6(config)#router bgp 65414

R6(config-router)#distancebgp 120 150 111

R6(config-router)#aggregate-address192.168.8.0 255.255.248.0 summary-only

R6上查看BGP路由表狀況:

R6#show ip route bgp

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B -BGP

       D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1,E2 - OSPF external type 2

       i - IS-IS, su - IS-ISsummary, 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 - periodicdownloaded static route, H - NHRP, l - LISP

       + - replicated route, % -next hop override

Gateway of last resort is not set

      4.0.0.0/32 is subnetted, 1subnets

B        4.4.4.4 [150/0] via 2.2.2.2, 00:08:24

      5.0.0.0/32 is subnetted, 1subnets

B       5.5.5.5 [120/0] via 56.1.1.1, 00:08:24

B    192.168.8.0/21 [111/0] via 0.0.0.0, 00:00:21, Null0

B     192.168.10.0/24 [150/0] via 2.2.2.2,00:00:21

B     192.168.11.0/24 [150/0] via 2.2.2.2,00:00:21

B     192.168.12.0/24 [150/0] via 2.2.2.2,00:00:21

從上可知,管理距離修改爲功。

相關文章
相關標籤/搜索