R3
#sh ip route
………………
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.1.1, 00:38:26
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/1
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [20/0] via 192.168.1.1, 00:37:56
(路径走向为R2)
C 192.168.1.0/24 is directly connected, Serial1/0
B 192.168.2.0/24 [200/0] via 10.1.1.2, 00:38:23
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.1.1, 00:38:26
R4#sh ip route
………………
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.2.2, 01:11:37
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/0
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [20/0] via 192.168.2.2, 01:11:37
B 192.168.1.0/24 [200/0] via 10.1.1.1, 01:11:37
C 192.168.2.0/24 is directly connected, FastEthernet0/0
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.2.2, 01:11:37
(R4都选择了R1走)
|
R3
#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>
130.130.1.0/24 192.168.1.1 0 64512 i
(选择R2走)
* i 192.168.2.2 0 100 0 64512 i
* i150.150.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* i172.16.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* 192.168.1.0 192.168.1.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.1.1 0 64512 i
*>i 10.1.1.2 0 100 0 i
R4
#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
* i10.1.1.0/24 10.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
* i130.130.1.0/24 192.168.1.1 0 100 0 64512 i
*>
192.168.2.2 0 0 64512 i
(直接走直连链路)
*> 150.150.1.0/24 192.168.2.2 0 64512 i
* i 192.168.1.1 0 100 0 64512 i
*> 172.16.1.0/24 192.168.2.2 0 0 64512 i
* i 192.168.1.1 0 100 0 64512 i
* 192.168.1.0 192.168.2.2 0 64512 i
*>i 10.1.1.1 0 100 0 i
* 192.168.2.0 192.168.2.2 0 0 64512 i
*> 0.0.0.0 0 32768 i
|
R2(config)#access-list 10 per 130.130.1.0 0.0.0.255
(建立一个对目的网段的ACL)
R2(config)#route-map bgp_med per 10 (
建立一个路由图名为bgp_med)
R2(config-route-map)#match ip add 10 (
匹配ACL)
R2(config-route-map)#set metric 10 (
匹配之后设置metric 值为10)
R2(config-route-map)#exit
R2(config)#route-map bgp_med per 20
(再建一个空路由图让其它的路由按默认的方式进行宣告)
R2(config-route-map)#exit
R2(config)#router bgp 64512
R2(config-router)#nei 192.168.1.2 route-map bgp_med out
(指定邻居后调用路由图方向是out)
|
R3#sh ip bgp
………………
Network Next Hop Metric LocPrf Weight Path
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* 130.130.1.0/24 192.168.1.1 10 0 64512 i
(192.168.1.1链路 MED值为10了)
*>
i 192.168.2.2 0 100 0 64512 i
(所以选择192.168.2.2链路了)
* i150.150.1.0/24 192.168.2.2 0 100 0 64512 i
*>
192.168.1.1 0 0 64512 i
(空路由图使其它链路都没变)
* i172.16.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* 192.168.1.0 192.168.1.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.1.1 0 64512 i
*>i 10.1.1.2 0 100 0 i
|
R4#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
* i10.1.1.0/24 10.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 130.130.1.0/24 192.168.2.2
0 0 64512 i
*> 150.150.1.0/24 192.168.2.2
0 64512 i
(路径没变)
* i 192.168.1.1 0 100 0 64512 i
(metric没有增加)
*> 172.16.1.0/24 192.168.2.2 0 0 64512 i
* i 192.168.1.1 0 100 0 64512 i
* 192.168.1.0 192.168.2.2 0 64512 i
*>i 10.1.1.1 0 100 0 i
* 192.168.2.0 192.168.2.2 0 0 64512 i
*> 0.0.0.0 0 32768 i
|
R4(config)#router bgp 64513
R4(config-router)#nei 10.1.1.1 next-hop-self
|
R3#sh ip route
……………………
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.1.1, 06:09:06
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/1
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [200/0] via 10.1.1.2, 00:01:45 (路径选择了R4)
C 192.168.1.0/24 is directly connected, Serial1/0
B 192.168.2.0/24 [200/0] via 10.1.1.2, 06:09:03
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.1.1, 06:09:06
|