BGP的選路

BGP的選路

1、實驗要求:
一、AS1去AS2走R2
二、AS2去AS1走R4
三、AS1去AS3走R6
四、AS2去AS3走R6
五、AS3去AS2走R5
六、AS3去AS1走R5
七、每一個選路規則只能使用一次
解決以上步驟的選路方法(事先沒有規劃):
一、local-preference
二、MED
三、Weight
四、Origin
五、AS-path
六、next-hopide

2、BGP的選路規則:
一、weight,範圍0-65535,默認爲0或32768,大優;
二、Local-preference,範圍0-65535,大優;
三、本地起源,起源與本地最優先;
四、As-path,通過AS的數量越少越憂,而且EBGP鄰居可添加AS的數量;
五、起源碼小憂,i-igp=0,e-egp=1,?-incomplete=2;
六、MED,小優;
七、EBGP路由優於IBGP路由,聯邦EBGP與普通IBGP不能使用該條進行比較,此時聯邦EBGP路由與IBGP相同;
八、最近的IGP鄰居,iIGP的metric最小的優;
九、若是配置了maximum-path [ibgp]n,若是存在多條等價路徑,會同時加載到路由表;
十、最老的路由,前提必須是external路由,聯邦內的EBGP路由當作IBGP 處理;
十一、最小的router-id優;
十二、多條路徑的router-id相同,那麼選擇cluster-list長度最短的;
1三、BGP優選來自最低鄰居IP地址的路由,BGP neighbor配置的那個IP地址。oop

3、配置:3d

R1#sho run | s pre
ip prefix-list AS2 seq 5 permit 3.3.3.0/24
ip prefix-list AS2 seq 10 permit 4.4.4.0/24
route-map AS2 permit 10
match ip address prefix-list AS2
set local-preference 80 //解決第一步是用的是local-preferencerouter

R1#sho run | s bgp
router bgp 1
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0
network 1.1.1.1 mask 255.255.255.255
neighbor 2.2.2.2 remote-as 1
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 100.1.13.3 remote-as 2
neighbor 100.1.13.3 route-map AS2 inblog

BGP的選路

R2#sho run | s pre
ip prefix-list AS3 seq 5 permit 6.6.6.0/24
ip prefix-list AS3 seq 10 permit 7.7.7.0/24
ip prefix-list AS3 seq 15 permit 5.5.5.0/24
route-map AS3 permit 10
match ip address prefix-list AS3
set weight 10 //解決第三步用的是weightip

R2#sho run | s bgp
router bgp 1
bgp log-neighbor-changes
network 2.2.2.0 mask 255.255.255.0
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 100.1.24.4 remote-as 2
neighbor 100.1.25.5 remote-as 3
neighbor 100.1.26.6 remote-as 3
neighbor 100.1.26.6 route-map AS3 inci

BGP的選路

R3#sho run | s pre
ip prefix-list AS1 seq 5 permit 1.1.1.0/24
ip prefix-list AS1 seq 10 permit 2.2.2.0/24
route-map AS1 permit 10
match ip address prefix-list AS1
set metric 100 //解決第二步用的是MED路由

R3#sho run | s bgp
router bgp 2
bgp log-neighbor-changes
network 3.3.3.0 mask 255.255.255.0
neighbor 4.4.4.4 remote-as 2
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 next-hop-self
neighbor 100.1.13.1 remote-as 1
neighbor 100.1.13.1 route-map AS1 inrem

BGP的選路

R4#sho run | s pre
ip prefix-list AS3 seq 5 permit 5.5.5.0/24
ip prefix-list AS3 seq 10 permit 6.6.6.0/24
ip prefix-list AS3 seq 15 permit 7.7.7.0/24
route-map AS3 permit 10
match ip address prefix-list AS3
set origin incomplete //解決第四步用的是origin源碼

R4#sho run | s bgp
router bgp 2
bgp log-neighbor-changes
network 4.4.4.0 mask 255.255.255.0
neighbor 3.3.3.3 remote-as 2
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 100.1.24.2 remote-as 1
neighbor 100.1.45.5 remote-as 3
neighbor 100.1.45.5 route-map AS3 in
neighbor 100.1.46.6 remote-as 3

BGP的選路

R5#sho run | s bgp
router bgp 3
bgp log-neighbor-changes
network 5.5.5.0 mask 255.255.255.0
neighbor 6.6.6.6 remote-as 3
neighbor 6.6.6.6 update-source Loopback0
neighbor 6.6.6.6 next-hop-self
neighbor 7.7.7.7 remote-as 3
neighbor 7.7.7.7 update-source Loopback0
neighbor 7.7.7.7 next-hop-self
neighbor 100.1.25.2 remote-as 1
neighbor 100.1.45.4 remote-as 2

BGP的選路

R6#sho run | s prefix-list AS1
ip prefix-list AS1 seq 5 permit 1.1.1.0/24
ip prefix-list AS1 seq 10 permit 2.2.2.0/24
route-map AS1 permit 10
match ip address prefix-list AS1
set as-path prepend 1 //第五步用的是as-path

R6#sho run | s prefix-list AS2
ip prefix-list AS2 seq 5 permit 3.3.3.0/24
ip prefix-list AS2 seq 10 permit 4.4.4.0/24
route-map AS2 permit 10
match ip address prefix-list AS2
set ip next-hop 5.5.5.5 //第六步用的是next-hop

R6#SHO run | s bgp
router bgp 3
bgp log-neighbor-changes
network 6.6.6.0 mask 255.255.255.0
neighbor 5.5.5.5 remote-as 3
neighbor 5.5.5.5 update-source Loopback0
neighbor 5.5.5.5 next-hop-self
neighbor 7.7.7.7 remote-as 3
neighbor 7.7.7.7 update-source Loopback0
neighbor 7.7.7.7 next-hop-self
neighbor 100.1.26.2 remote-as 1
neighbor 100.1.26.2 route-map AS1 in
neighbor 100.1.46.4 remote-as 2
neighbor 100.1.46.4 route-map AS2 in

BGP的選路

//在第六步,R6去AS2,沒有使用next-hop時,加表並優的是R4,加表不優的是R5,因爲使用了next-hop,
加表並優的路由變成R5,因此纔會看到BGP表中R6去AS2的優和不優的加表路由都成了R5。但實驗結果能過達到要求。

R6#traceroute 3.3.3.3 source 6.6.6.6 numeric
Type escape sequence to abort.
Tracing the route to 3.3.3.3
VRF info: (vrf in name/id, vrf out name/id)
1 100.1.56.5 0 msec 1 msec 0 msec
2 100.1.45.4 0 msec 1 msec 0 msec
3 100.1.34.3 1 msec * 1 msec
//測驗結果正確,能知足第六步要求

R7#sho run | s bgp
router bgp 3
bgp log-neighbor-changes
network 7.7.7.0 mask 255.255.255.0
neighbor 5.5.5.5 remote-as 3
neighbor 5.5.5.5 update-source Loopback0
neighbor 5.5.5.5 next-hop-self
neighbor 6.6.6.6 remote-as 3
neighbor 6.6.6.6 update-source Loopback0
neighbor 6.6.6.6 next-hop-self

BGP的選路

注意:本實驗的第六步選路方案雖實現了要求,但選路方案並不佳。因此,實驗前應對實驗中所要用到的選路規則進行推演,以便選出最好的選路方案。

相關文章
相關標籤/搜索