BGP路由選擇相關實驗

BGP有豐富的路由屬性。咱們一般控制BGP路由屬性,來控制BGP路由流向。
cisco路由器常見路由屬性以下:負載均衡

1.優先選擇最大weight(權重)的路由 (範圍:0~65535)
2.優先選擇有最大LOCAL_OREF(本地優先級)的路由 (範圍:0~4294967295)
3.優先選擇從本地路由器始發的路由 (即下一跳0.0.0.0)
4.優先選擇AS-path數量最少的路由
5.根據origin屬性,優先選擇具備最低起源類型的路由 (IGP優先於EGP優先於incomplete)
6.優先選擇具備最小MED值的路由 (範圍:0~4294967295)
7.EBGP優先於IBGP
8.優先選擇可以經過最近的IGP鄰居到達的路徑 (即對BGP下一跳具備最低IGP度量值的路徑)
9.若是配置了maximum-path N(2≤N≤6),可實現負載均衡 (但BGP會繼續比較,只有一條路徑被打上「>」標籤)
10.若是都是external(外部的)路由,優先選擇最老(即最先學到)的路由
11.優先選擇擁有最小BGP-router-ID的路由
12.若是是從路由反射器(RR)學習到的路由,優先選擇擁有最小cluster-ID(路由反射器的router-ID)的路由
13.優先選擇具備最低對等體地址接收到的路由(即鄰居IP地址最小的優先)ide

實驗拓撲圖
BGP路由選擇相關實驗oop

配置前R1上的路由
R1#sh 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 setcode

172.16.0.0/24 is subnetted, 2 subnets

C 172.16.12.0 is directly connected, FastEthernet0/0
C 172.16.13.0 is directly connected, FastEthernet0/1
10.0.0.0/32 is subnetted, 2 subnets
B 10.10.6.6 [20/0] via 172.16.12.2, 00:27:41
C 10.10.1.1 is directly connected, Loopback0router

使用weight改變路由blog

R1(config-router)#neighbor 172.16.13.3 weight 10
R1#clear ip bgp * softip

更改weight後路由
R1#sh 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 routeci

Gateway of last resort is not set路由

172.16.0.0/24 is subnetted, 2 subnets

C 172.16.12.0 is directly connected, FastEthernet0/0
C 172.16.13.0 is directly connected, FastEthernet0/1
10.0.0.0/32 is subnetted, 2 subnets
B 10.10.6.6 [20/0] via 172.16.13.3, 00:01:09
C 10.10.1.1 is directly connected, Loopback0

使用local-preference更改路由

更改R1配置:
R1(config)#ip prefix-list mei permit 10.10.6.6/32
R1(config)#route-map paul permit 10
R1(config-route-map)#match ip address prefix-list mei
R1(config-route-map)#set local-preference 200
R1(config)#route-map paul permit 99
R1(config-route-map)#router bgp 100
R1(config-router)#neighbor 172.16.13.3 remote-as 2345
R1(config-router)#neighbor 172.16.13.3 route-map mei in

R1(config-router)#do clear ip bgp * so
1(config-router)#do sh ip bgp 10.10.6.6/32
BGP routing table entry for 10.10.6.6/32, version 4
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x840
Advertised to update-groups:
1
2345 600
172.16.13.3 from 172.16.13.3 (10.10.3.3)
Origin IGP, localpref 200, valid, external, best
2345 600

使用AS-path更改路由
更改R1配置
R1(config-route-map)#do sh run | s route-map
route-map paul permit 10
match ip address prefix-list mei
set as-path prepend 100 100
route-map paul permit 99

R1(config-router)#do sh run | s bgp
router bgp 100
no synchronization
bgp router-id 10.10.1.1
bgp log-neighbor-changes
network 10.10.1.1 mask 255.255.255.255
neighbor 172.16.12.2 remote-as 2345
neighbor 172.16.12.2 route-map paul in
neighbor 172.16.13.3 remote-as 2345
no auto-summary

R1(config-router)#do clear ip bgp * so
R1(config-router)#do sh ip bgp 10.10.6.6
BGP routing table entry for 10.10.6.6/32, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1
100 100 2345 600
172.16.12.2 from 172.16.12.2 (10.10.2.2)
Origin IGP, localpref 100, valid, external
2345 600
172.16.13.3 from 172.16.13.3 (10.10.3.3)
Origin IGP, localpref 100, valid, external, best

使用MED更改路由
更改R1配置
R1(config-router)#do sh run | s route-map
neighbor 172.16.12.2 route-map paul in
route-map paul permit 10
match ip address prefix-list mei
set metric 10000
route-map paul permit 99
R1(config-router)#do sh run | s bgp
router bgp 100
no synchronization
bgp router-id 10.10.1.1
bgp log-neighbor-changes
network 10.10.1.1 mask 255.255.255.255
neighbor 172.16.12.2 remote-as 2345
neighbor 172.16.12.2 route-map paul in
neighbor 172.16.13.3 remote-as 2345
no auto-summary

R1(config-router)#do clear ip bgp * softR1(config-router)#do sh ip bgp 10.10.6.6/32BGP routing table entry for 10.10.6.6/32, version 2Paths: (2 available, best #1, table Default-IP-Routing-Table)Flag: 0x820Advertised to update-groups:12345 600172.16.13.3 from 172.16.13.3 (10.10.3.3)Origin IGP, localpref 100, valid, external, best2345 600172.16.12.2 from 172.16.12.2 (10.10.2.2)Origin IGP, metric 10000, localpref 100, valid, externalR1(config-router)#

相關文章
相關標籤/搜索