![图片[1]-4.6 优选限最小MED值路由-大赛人网](https://www.dsrw.com/wp-content/uploads/2023/03/图片7-22.png)
1.R1配置OSPF
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.255.255.255
2.R2配置OSPF
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.255.255.255
3.R1配置IBGP、EBGP
[R1]bgp 12
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 2.2.2.2 as-number 12
[R1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R1-bgp]peer 2.2.2.2 next-hop-local
[R1-bgp]peer 13.1.1.3 as-number 300
4.R2配置IBGP、EBGP
[R2]bgp 12
[R2-bgp]router-id 2.2.2.2
[R2-bgp]peer 1.1.1.1 as-number 12
[R2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[R2-bgp]peer 1.1.1.1 next-hop-local
[R2-bgp]peer 23.1.1.3 as-number 300
5.R3配置EBGP,宣告3.3.3.3/32到BGP
[R3]bgp 300
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 13.1.1.1 as-number 12
[R3-bgp]peer 23.1.1.2 as-number 12
[R3-bgp]network 3.3.3.3 32
6.R3针对R1使用策略方法修改MED值
[R3]ip ip-prefix dsrw.com permit 3.3.3.3 32
[R3]route-policy R1 permit node 10
[R3-route-policy]if-match ip-prefix dsrw.com
[R3-route-policy]apply cost 500
[R3-route-policy]quit
[R3]route-policy R1 permit node 20
7.R3针对R2使用策略方法修改MED值,在BGP应用策略
[R3]route-policy R2 permit node 10
[R3-route-policy]if-match ip-prefix dsrw.com
[R3-route-policy]apply cost 1000
[R3-route-policy]quit
[R3]route-policy R2 permit node 20
[R3]bgp 300
[R3-bgp]peer 13.1.1.1 route-policy R1 export
[R3-bgp]peer 23.1.1.2 route-policy R2 export
8.R1、R2查看BGP信息,选路都是从R1进入到AS300
<R3>refresh bgp all export
<R1>display bgp routing-table
*> 3.3.3.3/32 13.1.1.3 500 0 300i
<R2>display bgp routing-table
*>i 3.3.3.3/32 1.1.1.1 500 100 0 300i
* 23.1.1.3 1000 0 300i
9.MED值比较条件
在AS-PATH中,默认第一个AS号相同才进行比较,R1修改AS号。
[R1]ip ip-prefix dsrw.com permit 3.3.3.3 32
[R1]route-policy dsrw permit node 10
[R1-route-policy]if-match ip-prefix dsrw.com
[R1-route-policy]apply as-path 20 additive
[R1-route-policy]quit
[R1]route-policy dsrw permit node 20
[R1]bgp 12
[R1-bgp]peer 13.1.1.3 route-policy dsrw import
10.MED值比较条件
在AS-PATH中,默认第一个AS号相同才进行比较,R2修改AS号。
[R2]ip ip-prefix dsrw.com permit 3.3.3.3 32
[R2]route-policy dsrw permit node 10
[R2-route-policy]if-match ip-prefix dsrw.com
[R2-route-policy]apply as-path 10 additive
[R2-route-policy]quit
[R2]route-policy dsrw permit node 20
[R2]bgp 12
[R2-bgp]peer 23.1.1.3 route-policy dsrw import
11.R2查看BGP路由信息,AS-PATH不一致时,默认不比较MED值。
[R2]display bgp routing-table
*> 3.3.3.3/32 23.1.1.3 1000 0 10 300i
* i 1.1.1.1 500 100 0 20 300i
12.使用以下命令要求BGP比较,AS不一致时,开始比较MED值
[R2]bgp 12
[R2-bgp]compare-different-as-med
[R2]display bgp routing-table
*>i 3.3.3.3/32 1.1.1.1 500 100 0 20 300i
* 23.1.1.3 1000 0 10 300i
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容