BGP 管理距离修改及分析

    所谓管理距离(AD)就是指一种路由协议的可信度,对于多种不同的路由协议到同一个目的地的路由信息,路由器首先根据管理距离的大小决定相信哪一个路由协议。管理距离只用于多种协议的情况下会使用,同一路由协议中,选路按照该路由协议的选路机制,而不会用管理距离来选路。管理距离越小,其优先级越高,可信度越高。

wKiom1SWzaiiQYJdAAFXSXDGu7w866.jpg

如上图,在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 [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

从上可知,管理距离修改成功。


你可能感兴趣的:(修改,BGP,管理距离)