快捷搜索:  汽车  科技

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例从结果上来看已经满足需要,R1去访问12.12.12.12从R2走,R1去访问4.4.4.4从R3走。# bgp 1 router-id 2.2.2.2 peer 10.1.1.1 as-number 2 peer 10.3.1.4 as-number 1 # ipv4-family unicast undo synchronization peer 10.1.1.1 enable peer 10.1.1.1 route-policy MED export peer 10.1.1.1 next-hop-local peer 10.3.1.4 enable peer 10.3.1.4 next-hop-local # route-policy MED permit node 5 if-match ip-prefix MED apply cost 10

MULTI_EXIT_DISC属性(以下简称MED)是BGP协议在控制AS出口流量路径时经常用到的属性。MED属性的作用是在去往邻居AS存在多条链路时,允许AS为入站流量传达其优先级。(一般来说,比较不同AS的MED属性没有太大意义,特殊场景除外。)从MED属性的作用可以看出,MED属性只是作用于EBGP对等体,而IBGP对等体互相通告路由时,会忽略MED属性。MED属性常用于AS出口入方向流量的路径控制,MED属性值越小,路由越优。

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例(1)

案例拓扑

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例(2)

要求,所有访问12.12.12.12/32网段的流量必须从R2进入AS1,而所有访问4.4.4.4/32的流量必须从R3进入AS1。

实现方式使用路由策略,使R2在将12.12.12.12/32路由发往AS外部时(这里就是发给R1)携带的MED属性小于R3发送12.12.12.12/32路由时携带的MED属性。对于路由4.4.4.4/32同理。

关键配置

R2配置

# bgp 1 router-id 2.2.2.2 peer 10.1.1.1 as-number 2 peer 10.3.1.4 as-number 1 # ipv4-family unicast undo synchronization peer 10.1.1.1 enable peer 10.1.1.1 route-policy MED export peer 10.1.1.1 next-hop-local peer 10.3.1.4 enable peer 10.3.1.4 next-hop-local # route-policy MED permit node 5 if-match ip-prefix MED apply cost 10 # route-policy MED permit node 10 ip ip-prefix MED index 10 permit 4.4.4.4 32 return

R3配置

bgp 1 router-id 3.3.3.3 peer 10.2.1.1 as-number 2 peer 10.4.1.4 as-number 1 # ipv4-family unicast undo synchronization peer 10.2.1.1 enable peer 10.2.1.1 route-policy MED export peer 10.2.1.1 next-hop-local peer 10.4.1.4 enable peer 10.4.1.4 next-hop-local # route-policy MED permit node 5 if-match ip-prefix MED apply cost 10 # route-policy MED permit node 10 ip ip-prefix MED index 10 permit 12.12.12.12 32 return

配置完成后,查看R1的BGP路由表:

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例(3)

可以看到去往12.12.12.12/32目的地有两条路由,下一跳为R2的路由被优选,因为其MED值较小。4.4.4.4/32的路由同理。

验证结果

bgp路由传递规则,BGP路由协议中MULTIEXITDISC属性的应用案例(4)

从结果上来看已经满足需要,R1去访问12.12.12.12从R2走,R1去访问4.4.4.4从R3走。

猜您喜欢: