我們按照上一期28配置情況繼續往下,在R4我們可以通過查看BGP數據庫發現22.1.1.1和11.1.1.1 前面都帶r, 意味著這兩個路由是通過IGP OSPF學到的更優路由。
其中11.1.1.1是重分佈進來的路由,22.1.1.1是ospf學到的路由:
BGP重分佈到IGP,應用route-map做過濾:
我們在R2 使用重分佈BGP到OSPF的時候可以使用route-map,因為BGP的路由條目數可能比較大,使用精確匹配BGP重分佈到OSPF。
R2(config)#access-list 1 permit 11.1.1.1 0.0.0.0
R2(config)#route-map B2o permit 10
R2(config-route-map)#match ip address 1
R2(config)#router ospf 110
R2(config-router)#redistribute bgp 200 subnets route-map B2o
我們如果僅僅在R2重分佈BGP到OSPF,此時R4的重分佈去掉,我們查看下R2路由表:
*>i 55.1.1.1/32 ------i代表從IBGP得到的路由,對BGP來講,默認情況只把從EBGP得到的路由重分佈到IGP(防止路由環路) ,需要單獨配置這個功能,這個功能非常危險的容易引起環路,一般不會這樣配。
R2(config)#router ospf 11
R2(config-router)#no redistribute bgp 200 subnets route-map B2o
R2(config-router)#redistribute bgp 200 subnets ---為了方便演示效果我們把route-map去掉
然後我們在R3 ospf路由表雖然會發現55.1.1.1的外部路由,此時是有問題的:
R3# sho ip cef 55.1.1.1 detail
55.1.1.1/32, epoch 0
nexthop 23.1.1.2 Serial1/2 ----發現到55.1.1.1下一跳為23.1.1.2 為R2
R2#show ip cef 55.1.1.1 detail
55.1.1.1/32, epoch 0, flags [rib only nolabel, rib defined all labels]
recursive via 44.1.1.1
nexthop 23.1.1.3 Serial1/2---------R2的下一跳又到達R3,因此出現環路
我們從R1 做traceroute 發現路由在R2和R3之間出現環路:
解決路由黑洞的集中可選方案:
1、BGP的防環機制,其一針對IBGP:
IBGP的水平分割原則,針對IBGP鄰居僅僅傳遞一跳,所以此時需要全互聯(BGP的session過多)
R3#show ip bgp neighbors 44.1.1.1 advertised-routes ---R3沒有發現向IBGP鄰居R4通過的路由
Total number of prefixes 0
我們已經在R2和R4之間建立的IBGP鄰居關係,現在我們在R2和R3及R3和R4之間建立鄰居關係
R2的BGP配置:
router bgp 200
network 22.1.1.1 mask 255.255.255.255
neighbor 12.1.1.1 remote-as 100
neighbor 33.1.1.1 remote-as 200
neighbor 33.1.1.1 update-source Loopback0
neighbor 33.1.1.1 next-hop-self
neighbor 44.1.1.1 remote-as 200
neighbor 44.1.1.1 update-source Loopback0
neighbor 44.1.1.1 next-hop-self
R3的BGP配置:
R3#sho run | s bgp
router bgp 200
neighbor 22.1.1.1 remote-as 200
neighbor 22.1.1.1 update-source Loopback0
neighbor 44.1.1.1 remote-as 200
neighbor 44.1.1.1 update-source Loopback0
R4的BGP配置:
R4#show run | s bgp
router bgp 200
neighbor 22.1.1.1 remote-as 200
neighbor 22.1.1.1 update-source Loopback0
neighbor 22.1.1.1 next-hop-self
neighbor 33.1.1.1 remote-as 200
neighbor 33.1.1.1 update-source Loopback0
neighbor 33.1.1.1 next-hop-self
neighbor 45.1.1.5 remote-as 300
此時我們在R5做路由跟蹤和ping 11.1.1.1 :
2、其二針對EBGP防環機制:
AS-Path: 當在路由更新中,as-path list包含本設備的as時,將拒絕接收該路由
我們在R1和R5之間建立EBGP鄰居
R1(config)#router bgp 100
R1(config-router)#neighbor 15.1.1.5 remote-as 300
然後我們在R5查看R5通告給R1的BGP路由:
R1#debug ip bgp updates
R5#clear ip bgp * soft
R1拒絕接收包含本設備AS的路由。
R1(config)#router bgp 100
R1(config-router)#address-family ipv4
R1(config-router-af)#neighbor 15.1.1.5 allowas-in 1 ----允許含有本設備AS的路由更新進來
一般不需要做這個,沒有特殊場景不需要做這個
R1(config-router-af)#no neighbor 15.1.1.5 allowas-in
R1#clear ip bgp * soft 恢復正常:
R1 和R5我們暫時不用,我們把鄰居先關閉:
R1(config)#router bgp 100
R1(config-router)#neighbor 15.1.1.5 shutdown
解決路由黑洞4 MPLS:多協議標籤交換協議(數據轉發 路由控制分開) 2.5層標籤轉發 後面再細講
R5(config)#no router bgp 300
R5(config)#router bgp 65535.65535
R5(config-router)#neighbor 45.1.1.4 remote-as 200
R4進行配置
R4(config)#router bgp 200
R4(config-router)#neighbor 45.1.1.5 remote-as 65535.65535
R5#sho run | s bgp
router bgp 4294967295 ----十進制表示
bgp log-neighbor-changes
neighbor 45.1.1.4 remote-as 200
R5(config)#router bgp 65535.65535
R5(config-router)#bgp asnotation dot
R5#show run | s bgp
router bgp 65535.65535 -----配置bgp asnotation dot 後以點的形式表示
bgp asnotation dot
bgp log-neighbor-changes
neighbor 45.1.1.4 remote-as 200
BGP源的問題:
如果R2沒有配置update-source Loopback0, R4配置更新源 我們配置下面命令後R2主動發起建立鄰居默認使用物理出接口與R4 lo口R4則與R2的lo0此時方向不一致導致鄰居建立失敗,因此需要R2配置更新源lo0( neighbor 44.1.1.1 update-source Loopback0)
R2(config-router)#neighbor 44.1.1.1 transport connection-mode active
歡迎關注和轉發,更多精彩內容下期繼續分享!
閱讀更多 專注分享網絡技術 的文章