R3(config)#access-list 1 permit 172.16.1.0 0.0.0 .0
//
利用
ACL
抓取某条路由时,建议反掩码写成
0.0.0
.0
R3(config)#route-map R1-172
R3(config-route-map)#match ip address 1
R3(config-route-map)#set weight 100
//
修改
ACL1
中路由的
weihgt
R3(config)#route-map R1-172 20
//route-map
中隐含条目最后一条是
deny any
,所以这里一定要补充这么一句
R3(config-route-map)#exit
R3(config)#router bgp 1
R3(config-router)#neighbor 13.1.1 .1 route-map R1 -172 in
//
从邻居
13.1.1
.1
发进来的
ACL1
中定义的路由,应用
route-map R1-172
R3(config)#access-list 2 permit 192.168.1.0
R3(config)#route-map R4-192
R3(config-route-map)#match ip add 2
R3(config-route-map)#set weight 200
R3(config-route-map)#exit
R3(config)#route-map R4-192 20
R3(config-route-map)#exit
R3(config)#router bgp 1
R3(config-router)#neighbor 34.1.1.4 route-map R4 -192 in
R3#clear ip bgp * soft
//刚才忘了,呵呵。要使修改生效,一定要手动软启一下BGP
=====================
验证
=======================
R3#sh ip bgp
BGP table version is 5, local router ID is 3.3.3 .3
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 34.1.1.4 0 100 0 2 i
*>i 13.1.1 .1 0 100 100 2 i
*>i192.168.1.0 34.1.1.4 0 100 200 2 i
* i 13.1.1 .1 0 100 0 2 i
R3#traceroute 192.168.1.1 source 10.1.1 .1
//
我在
R3
的
loopback 0
上建了一个
10.1.1
.1
的端口,并宣告进
BGP
中用来测试
Type escape sequence to abort.
Tracing the route to 192.168.1.1
1 34.1.1.4 48 msec 64 msec 112 msec
2 24.1.1.2 116 msec 136 msec *
R3#traceroute 172.16.1.1 source 10.1.1 .1
Type escape sequence to abort.
Tracing the route to 172.16.1.1
1 13.1.1 .1 44 msec 80 msec 76 msec
2 12.1.1 .2 152 msec 128 msec *