需求:
R1發佈環回口地址1.1.1.1給R2攜帶團體屬性1111:1111,R3發佈環回口地址1.1.1.1給R2攜帶團體屬性1111:1111,R4發佈1.1.1.1給R2不攜帶團體屬性,測試在R2發送給R5的BGP路由表象中1.1.1.1是否攜帶團體屬性值1111:1111?node
AS規劃:
R1 AS 100
R2 AS 200
R3 AS 300
R4 AS 400
R5 AS 500session
拓撲環境:
R1配置:app
<R1>dis ip int b *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 up up 12.1.1.1 -- GE0/1 down down -- -- GE0/2 down down -- -- GE5/0 down down -- -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Loop0 up up(s) 1.1.1.1 -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- -- <R1>dis cu conf bgp # bgp 100 peer 12.1.1.2 as-number 200 # address-family ipv4 unicast network 1.1.1.1 255.255.255.255 route-policy com peer 12.1.1.2 enable peer 12.1.1.2 advertise-community # <R1>dis cu conf route-policy # route-policy com permit node 10 apply community 1111:1111 # return
R2配置:負載均衡
<R2>dis ip int b *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 up up 12.1.1.2 -- GE0/1 up up 23.1.1.2 -- GE0/2 up up 24.1.1.2 -- GE5/0 up up 25.1.1.2 -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- -- <R2> <R2>dis cu conf bgp # bgp 200 peer 12.1.1.1 as-number 100 peer 23.1.1.3 as-number 300 peer 24.1.1.4 as-number 400 peer 25.1.1.5 as-number 500 # address-family ipv4 unicast balance 32 //負載均衡配置 balance as-path-relax //忽略比較AS內容 peer 12.1.1.1 enable peer 23.1.1.3 enable peer 24.1.1.4 enable peer 25.1.1.5 enable peer 25.1.1.5 advertise-community #
R3配置:ide
<R3>dis ip int b *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 down down -- -- GE0/1 up up 23.1.1.3 -- GE0/2 down down -- -- GE5/0 down down -- -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Loop0 up up(s) 1.1.1.1 -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- -- <R3> <R3>dis cu conf bgp # bgp 300 peer 23.1.1.2 as-number 200 # address-family ipv4 unicast network 1.1.1.1 255.255.255.255 route-policy com peer 23.1.1.2 enable peer 23.1.1.2 advertise-community # return <R3> <R3>dis cu conf route-po <R3>dis cu conf route-policy # route-policy com permit node 10 apply community 1111:1111 #
R4配置:oop
<R4>dis ip int b *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 down down -- -- GE0/1 down down -- -- GE0/2 up up 24.1.1.4 -- GE5/0 down down -- -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Loop0 up up(s) 1.1.1.1 -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- -- <R4> <R4>dis cu conf bgp # bgp 400 peer 24.1.1.2 as-number 200 # address-family ipv4 unicast network 1.1.1.1 255.255.255.255 peer 24.1.1.2 enable # return
R5配置:測試
<R5>dis ip int b *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 down down -- -- GE0/1 down down -- -- GE0/2 down down -- -- GE5/0 up up 25.1.1.5 -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- -- <R5>dis cu conf bgp # bgp 500 peer 25.1.1.2 as-number 200 # address-family ipv4 unicast peer 25.1.1.2 enable # return
測試:
在R2上查看BGP ECMP負載狀況:debug
<R2>dis bgp peer ipv4 BGP local router ID: 25.1.1.2 Local AS number: 200 Total number of peers: 4 Peers in established state: 4 * - Dynamically created peer Peer AS MsgRcvd MsgSent OutQ PrefRcv Up/Down State 12.1.1.1 100 22 20 0 1 00:13:08 Established 23.1.1.3 300 23 21 0 1 00:13:08 Established 24.1.1.4 400 20 19 0 1 00:13:08 Established 25.1.1.5 500 3 4 0 0 00:00:25 Established <R2>dis bgp routing-table ipv4 //經過在R2上查看路由,確認是負載均衡狀態 Total number of routes: 3 BGP local router ID is 25.1.1.2 Status codes: * - valid, > - best, d - dampened, h - history s - suppressed, S - stale, i - internal, e - external a - additional-path Origin: i - IGP, e - EGP, ? - incomplete Network NextHop MED LocPrf PrefVal Path/Ogn * >e 1.1.1.1/32 12.1.1.1 0 0 100i * >e 23.1.1.3 0 0 300i * >e 24.1.1.4 0 0 400i <R2> <R2>dis ip routing-table Destinations : 25 Routes : 27 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0 1.1.1.1/32 BGP 255 0 12.1.1.1 GE0/0 23.1.1.3 GE0/1 24.1.1.4 GE0/2 12.1.1.0/24 Direct 0 0 12.1.1.2 GE0/0
一、R一、R3先通告EBGP路由1.1.1.1,而後再在R4上經過EBGP路由1.1.1.1
開啓R5側debug,確認R5側收到BGP update更新報文攜帶團體屬性1111:1111code
<R5>t m The current terminal is enabled to display logs. <R5>t d The current terminal is enabled to display debugging logs. <R5>deb <R5>debugging bgp u <R5>debugging bgp update <R5>reset bgp all Reset BGP sessions? [Y/N]:y <R5>%Jan 4 01:51:15:752 2020 R5 BGP/5/BGP_STATE_CHANGED: BGP default.: 25.1.1.2 state has changed from ESTABLISHED to IDLE for administrative reset. <R5>%Jan 4 01:51:18:002 2020 R5 BGP/5/BGP_STATE_CHANGED: BGP default.: 25.1.1.2 State is changed from OPENCONFIRM to ESTABLISHED. <R5> <R5>*Jan 4 01:51:18:228 2020 R5 BGP/7/DEBUG: BGP.: Recv UPDATE from peer 25.1.1.2 with following destinations: Update message length : 59 Origin : IGP AS path : 200 100 Next hop : 25.1.1.2 Community : <1111:1111> 1.1.1.1/32 PathID 0 , <R5>dis bgp rou ipv4 1.1.1.1 BGP local router ID: 25.1.1.5 Local AS number: 500 Paths: 1 available, 1 best BGP routing table information of 1.1.1.1/32: From : 25.1.1.2 (25.1.1.2) Rely nexthop : 25.1.1.2 Original nexthop: 25.1.1.2 OutLabel : NULL Community : <1111:1111> RxPathID : 0x0 TxPathID : 0x0 AS-path : 200 100 Origin : igp Attribute value : pref-val 0 State : valid, external, best IP precedence : N/A QoS local ID : N/A Traffic index : N/A null
二、R2先通告EBGP路由1.1.1.1,而後再在R一、R3上經過EBGP路由1.1.1.1orm
[R5]%Jan 9 00:12:58:312 2020 R5 BGP/5/BGP_STATE_CHANGED: BGP default.: 25.1.1.2 State is changed from OPENCONFIRM to ESTABLISHED. *Jan 9 00:12:58:459 2020 R5 BGP/7/DEBUG: BGP.: Recv UPDATE from peer 25.1.1.2 with following destinations: Update message length : 52 Origin : IGP AS path : 200 400 Next hop : 25.1.1.2 1.1.1.1/32 PathID 0 , <R5>dis bgp rou ipv4 1.1.1.1 BGP local router ID: 25.1.1.5 Local AS number: 500 Paths: 1 available, 1 best BGP routing table information of 1.1.1.1/32: From : 25.1.1.2 (25.1.1.2) Rely nexthop : 25.1.1.2 Original nexthop: 25.1.1.2 OutLabel : NULL RxPathID : 0x0 TxPathID : 0x0 AS-path : 200 400 Origin : igp Attribute value : pref-val 0 State : valid, external, best IP precedence : N/A QoS local ID : N/A Traffic index : N/A
結論:在EBGP ECMP負載均衡環境中,當不一樣的EBGP 宣告者分別發佈既帶有團體屬性的community屬性值和不帶團體屬性的community屬性的業務網段時,最終EBGP接收者會將最先發布路由更新的Speaker宣告者的路由條目放到本身的BGP路由表象中。即以最先收到的路由爲原則,最早收到誰的路由,就將誰的路由放置到路由表象中。