(CCNP)BGP改变metric和本地优先级影响路径选择
2012-11-01 16:44
573 查看
r1:
inter f0/0
ip add 192.168.1.1 255.255.255.0
no sh
inter e1/0
ip add 192.168.6.2 255.255.255.0
no sh
router bgp 1 //启用bgp路由,as为1
nei 192.168.1.2 remoet-as 1 //定义ibgp邻居
nei 192.168.6.2 remote-as 1 //定义ibgp邻居
net 192.168.1.0 //通告路由到bgp
net 192.168.6.0 //通告路由到bgp
r2:
inter e1/0
ip add 192.168.1.2 255.255.255.0
no sh
inter f0/0
ip add 192.168.2.1 255.255.255.0
no sh
router bgp 1 //启用bgp路由,as为1
nei 192.168.1.1 remote-as 1 //定义ibgp邻居
nei 192.168.2.2 remote-as 2 //定义ebgp邻居
nei 192.168.2.2 route-map set-med out //引用名为set-med的route-map,作用为当通告给邻居路由的时候改变metric
nei 192.168.2.2 route-map set-lo in //引用名为set-lo的route-map,作用为当邻居通告路由进入as1时改变本地优先级
net 192.168.1.0 //通告路由到bgp
net 192.168.2.0 //通告路由到bgp
access-list 1 permit 192.168.1.0 //这是改变metric引用的acl
access-list 2 permit 192.168.2.0 //这是改变metric引用的acl
access-list 3 permit 172.16.1.0 //这是改变本地优先级引用的acl
route-map set-med permit 10 //改变metric的route-map,序列号为10
match ip add 1 //同acl1匹配
set metric 100 //如果匹配就将metric改为100
ex
route-map set-med permit 20 //改变metric的route-map,序列号为20
match ip add 2 //同acl2匹配
set metric 200 //如果匹配就将metric改为200
ex
route-map set-lo permit 10 //改变本地优先级的route-map,序列号为10
match ip add 3 //引用acl3
set local-preference 100 //如果匹配就将本地优先级改为100
route-map set-lo permit 20 //没有match的route-map同所有的条目匹配
ex
end
clear ip bgp 192.168.2.2 soft //软重置邻居192.168.2.2,注意这条命令是在特权模式下使用的
r3:
inter e1/0
ip add 192.168.6.1 255.255.255.0 //r3的配置同r2差不多,不再多说
no sh
inter f0/0
ip add 192.168.5.2 255.255.255.0
ex
router bgp 1
nei 192.168.6.2 remote-as 1
nei 192.168.5.1 remote-as 2
net 192.168.6.0
net 192.168.5.0
nei 192.168.5.1 route-map set-med out
nei 192.168.5.1 route-map set-lo in
ex
access-list 1 permit 192.168.1.0
access-list 2 permit 192.168.6.0
access-list 3 permit 172.16.1.0
route-map set-med permit 10
match ip add 1
set metric 200
ex
route-map set-med permit 20
match ip add 2
set metric 100
route-map set-lo permit 10
match ip add 3
set local-preference 200
ex
route-map set-lo permit 20
ex
end
clear ip bgp 192.168.5.1 soft
r4:
inter e1/0
ip add 192.168.2.2 255.255.255.0
no sh
inter f0/0
ip add 192.168.3.1 255.255.255.0
no sh
router bgp 2
nei 192.168.2.1 remote-as 1
nei 192.168.3.2 remote-as 2
net 192.168.2.0
net 192.168.3.0
r5:
inter e1/0
ip add 192.168.5.1 255.255.255.0
no sh
inter f0/0
ip add 192.168.4.2 255.255.255.0
no sh
router bgp 2
nei 192.168.5.2 remote-as 1
nei 192.168.4.1 remote-as 2
net 192.168.5.0
net 192.168.4.0
r6:
inter e1/0
ip add 192.168.3.2 255.255.255.0
no sh
inter e1/1
ip add 192.168.4.1 255.255.255.0
no sh
inter loop 1
ip add 172.16.1.1 255.255.255.0
router bgp 2
nei 192.168.3.1 remote-as 2
nei 192.168.4.2 remote-as 2
r6在用route-map改变metric前的bgp路径,可以清楚的看到前往192.168.1.0和192.168.6.0的metric值为0,而且下一跳都为
192.168.2.1
R6(config-if)#do show ip bgp
BGP table version is 14, local router ID is 192.168.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.16.1.0/24 0.0.0.0 0 32768 i
* i192.168.1.0 192.168.5.2 0 100 0 1 i
*>i 192.168.2.1 0 100 0 1 i
*>i192.168.2.0 192.168.3.1 0 100 0 i
*> 192.168.3.0 0.0.0.0 0 32768 i
* i 192.168.3.1 0 100 0 i
*> 192.168.4.0 0.0.0.0 0 32768 i
* i 192.168.4.2 0 100 0 i
*>i192.168.5.0 192.168.4.2 0 100 0 i
* i192.168.6.0 192.168.5.2 0 100 0 1 i
*>i 192.168.2.1 0 100 0 1 i
用route-map改变metric后,可以看到ibgp邻居192.168.3.1通告的前往192.168.1.0和192.168.6.0的metric分别变为100和200,而
ibgp邻居192.168.4.2通告的前往192.168.1.0和192.168.6.0的metric分别为200和100.med值越小越好这导致r6前往192.168.1.0通过
r2,而前往192.168.6.0通r3.
R6#show ip bgp
BGP table version is 18, local router ID is 192.168.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 172.16.1.0/24 0.0.0.0 0 32768 i
* i192.168.1.0 192.168.5.2 200 100 0 1 i
*>i 192.168.2.1 100 100 0 1 i
*>i192.168.2.0 192.168.3.1 0 100 0 i
*> 192.168.3.0 0.0.0.0 0 32768 i
* i 192.168.3.1 0 100 0 i
*> 192.168.4.0 0.0.0.0 0 32768 i
* i 192.168.4.2 0 100 0 i
*>i192.168.5.0 192.168.4.2 0 100 0 i
*>i192.168.6.0 192.168.5.2 100 100 0 1 i
* i 192.168.2.1 200 100 0 1 i
r1上前往172.16.1.0是经过r2的
R1#show ip bgp
BGP table version is 9, local router ID is 192.168.6.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i172.16.1.0/24 192.168.5.1 0 100 0 2 i
*>i 192.168.2.2 0 100 0 2 i
* i192.168.1.0 192.168.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i192.168.2.0 192.168.1.2 0 100 0 i
* i192.168.3.0 192.168.5.1 0 100 0 2 i
*>i 192.168.2.2 0 100 0 2 i
*>i192.168.4.0 192.168.2.2 0 100 0 2 i
* i 192.168.5.1 0 100 0 2 i
*>i192.168.5.0 192.168.6.1 0 100 0 i
* i192.168.6.0 192.168.6.1 0 100 0 i
*> 0.0.0.0 0 32768 i
本地优先级值越大越好,修改优先级后通过r3前往172.16.1.0的本地优先级为200比r2通告的优先级高,所以通过r3前往172.16.1.0
R1#show ip bgp
BGP table version is 10, local router ID is 192.168.6.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i172.16.1.0/24 192.168.5.1 0 200 0 2 i
* i 192.168.2.2 0 100 0 2 i
* i192.168.1.0 192.168.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i192.168.2.0 192.168.1.2 0 100 0 i
* i192.168.3.0 192.168.5.1 0 100 0 2 i
*>i 192.168.2.2 0 100 0 2 i
*>i192.168.4.0 192.168.2.2 0 100 0 2 i
* i 192.168.5.1 0 100 0 2 i
*>i192.168.5.0 192.168.6.1 0 100 0 i
* i192.168.6.0 192.168.6.1 0 100 0 i
*> 0.0.0.0 0 32768 i
本文出自 “话巴山夜雨时” 博客,请务必保留此出处http://ccnpnetwork.blog.51cto.com/1648283/1046986
相关文章推荐
- CCNP-BGP选路实验-本地优先级、as-path探讨route-map
- android选择本地相册图片路径的问题的解决
- CCNP路由-19 BGP路径属性详解(下)
- BGP最优路径选择算法
- BGP 最佳路径选择之 -- Origin
- CCNP路由-18 BGP路径属性详解(上)
- 实验指南:BGP路径选择
- 通过BGP路径欺骗来影响BGP的路由选择
- 改变TFS本地映射路径.
- BGP路径的选择---修改权重(weight)
- 关于 小米手机 从本地选择照片路径为null
- IE上传本地文件时,无需改变浏览器设置就能完美得到完整路径的解决方案
- JS+ACTIVEX实现网页选择本地目录路径对话框
- BGP路径选择次序
- 多路径路由算法选择(2)——回顾传统的动态路由协议(RIP、OSPF、BGP、IGRP、EIGRP、IS-IS)
- 一个拓扑全搞定 - - 之 BGP13条路径选择算法 - 案例分析
- Forwarding Address对LSA5的路径选择影响
- 改变TFS本地映射路径.
- 操纵BGP路径选择---local preference属性案例(配图+详细验证过程)
- FileUpLoad选择图片后,直接将图片显示在image中。及IE8本地路径("C:/fakepath/")出现问题的解决方案