我们按照上一期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
欢迎关注和转发,更多精彩内容下期继续分享!
閱讀更多 專注分享網絡技術 的文章