R1#sh ip route
………………
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.4.0/24 is directly connected, FastEthernet0/0
C 192.168.1.0/24 is directly connected, Serial1/1
B 192.168.2.0/24 [20/0] via 192.168.1.2, 00:09:18
B 192.168.3.0/24 [20/0] via 192.168.4.1, 00:09:11
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.1.2, 00:09:18
R1#sh ip bgp
BGP table version is 7, local router ID is 192.168.4.2
………………
Network Next Hop Metric LocPrf Weight Path
* 150.150.1.0/24 192.168.4.1 0 64515 64514 i
*> 192.168.1.2 0 64513 64514 i
* 192.168.1.0 192.168.1.2 0 0 64513 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.4.1 0 64515 64514 i
*> 192.168.1.2 0 0 64513 i
*> 192.168.3.0 192.168.4.1 0 0 64515 i
* 192.168.1.2 0 64513 64514 i
* 192.168.4.0 192.168.4.1 0 0 64515 i
*> 0.0.0.0 0 32768 i
|
R1#sh ip bgp neighbors
BGP neighbor is 192.168.1.2, remote AS 64513, external link
BGP version 4, remote router ID 192.168.2.1
BGP state = Established, up for 00:53:38
……………… BGP neighbor is 192.168.4.1, remote AS 64515, external link
BGP version 4, remote router ID 192.168.4.1
BGP state = Established, up for 00:54:23
|
R1(config)#router bgp 64512
R1(config-router)#nei 192.168.1.2 weight 50
R1(config-router)#nei 192.168.4.1 weight 100
|
R1#clear ip bgp * soft
R1#sh ip bgp
Network Next Hop Metric LocPrf Weight Path
*>
150.150.1.0/24 192.168.4.1 100 64515 64514 i
(现在选择R4了)
* 192.168.1.2 50 64513 64514 i
* 192.168.1.0 192.168.1.2 0 50 64513 i
(这条没错)
*> 0.0.0.0 0 32768 i
*>
192.168.2.0 192.168.4.1 100 64515 64514 i
(但这条路径就……)
* 192.168.1.2 0 50 64513 i
*> 192.168.3.0 192.168.4.1 0 100 64515 i
* 192.168.1.2 50 64513 64514 i
* 192.168.4.0 192.168.4.1 0 100 64515 i
*> 0.0.0.0 0 32768
i
(为避免环路,直连权重值为最大)
|
R1(config)#router bgp 64512
R1(config-router)#no neighbor 192.168.1.2 weight 50
R1(config-router)#no neighbor 192.168.4.1 weight 100
R1(config)#access-list 10 per 150.150.1.0 0.0.0.255
(建立一个ACL)
R1(config)#route-map set_weight per 10
(建立一个路由图名为set_weight)
R1(config-route-map)#match ip add 10 (
匹配ACL)
R1(config-route-map)#set weight 100
(针对route-map特定的目的网络设置权重值100)
R1(config-route-map)#exit
R1(config)#route-map set_weight per 20
(再建立一个空路由图以便其它路由都按默认方式转发)
|
R1#sh ip bgp
…………
Network Next Hop Metric LocPrf Weight Path
*>
150.150.1.0/24 192.168.4.1 0 64515 64514 i
(下一跳为R4)
* 192.168.1.2 0 64513 64514 i
* 192.168.1.0 192.168.1.2 0 0 64513 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.4.1 0 64515 64514 i
*>
192.168.1.2 0 0 64513 i (
下一跳为R2)
*> 192.168.3.0 192.168.4.1 0 0 64515 i
* 192.168.1.2 0 64513 64514 i
* 192.168.4.0 192.168.4.1 0 0 64515 i
*> 0.0.0.0 0 32768 i
R1#sh ip route
………………
C 192.168.4.0/24 is directly connected, FastEthernet0/0
C 192.168.1.0/24 is directly connected, Serial1/1
B 192.168.2.0/24 [20/0] via 192.168.1.2, 00:07:40
B 192.168.3.0/24 [20/0] via 192.168.4.1, 00:32:27
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.4.1, 00:07:40
|