拓扑图
R1、R2、R4之间运行rip,其中R2的环回在rip中
R2、R3、R4之间运行ospf,其中R4的环回在ospf中
在R2和R4路由器中做双向重发布,并且将ospf重发布进rip时指定种子度量值为1,重发布的顺序为:R2:rip··>ospf
R4:ospf··>rip
R4:rip··>ospf
R2:ospf··>rip
此图构成双点双向重发布。
双点双向重发布(rip和ospf之间)会产生两个问题:
1,路由回馈
3,选路不佳
R1路由表
R1#sho ip route rip
34.0.0.0/24 is subnetted, 1 subnets
R 34.1.1.0 [120/1] via 14.1.1.1, 00:00:27, Serial1/0
[120/1] via 12.1.1.2, 00:00:20, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/1] via 14.1.1.1, 00:00:27, Serial1/0
[120/1] via 12.1.1.2, 00:00:20, Serial1/1
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 14.1.1.1, 00:00:27, Serial1/0
[120/1] via 12.1.1.2, 00:00:20, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/1] via 14.1.1.1, 00:00:27, Serial1/0
[120/1] via 12.1.1.2, 00:00:20, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
R 23.1.1.0 [120/1] via 14.1.1.1, 00:00:27, Serial1/0
[120/1] via 12.1.1.2, 00:00:20, Serial1/1
R1到达所有网段全部负载均衡,这显然不正确。
R1到达3.3.3.0/24应该负载均衡才是正确的。
比如R1到达2.2.2.0/24网段负载均衡,走12.1.1.2没问题(通过rip学习到metric值为1),但是不能走14.1.1.1,这是因为,R2将2.2.2.0/24这条路由重发布进ospf,R4又将这条路由重发布进rip,由于重发布时种子度量值为1,AD值相同,R1通过R2和R4学习到的这条路由metric值一样,所以负载均衡。
其他网段负载均衡也是一样的原因。这就是路由回馈现象,属于rip的路由重发布进ospf,又被ospf重发布回到rip,路由回馈导致的选路不佳。
R4的路由表
R4#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 34.1.1.1, 00:39:41, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 34.1.1.1, 00:39:41, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/65] via 34.1.1.1, 00:40:39, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/128] via 34.1.1.1, 00:40:39, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
O E2 12.1.1.0 [110/20] via 34.1.1.1, 00:39:42, Serial1/0
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial1/1
R4通过ospf学习到的三条OE2路由本应该通过rip学习才是正确的,这是因为通过rip学习到的这三条路由AD值为120,而这三条路由被R2重发布进ospf时AD值为110,故R4优选了ospf的路由,从而导致的选路不佳,那么只要让R4学到的这三条路由AD大于120,那么R4就不会优选ospf的路由。
R4(config)#access-list 1 permit 1.1.1.0 //通过acl抓取到这三条路由
R4(config)#access-list 1 permit 2.2.2.0
R4(config)#access-list 1 permit 12.1.1.0
R4(config-router)#distance 121 92.2.2.2 0.0.0.0 1 //把R2传给我的三条路由AD值改为121
此时查看R4的路由表
R4#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 14.1.1.2, 00:00:18, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [121/20] via 34.1.1.1, 00:03:14, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/65] via 34.1.1.1, 00:03:14, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/128] via 34.1.1.1, 00:03:14, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
R 12.1.1.0 [120/1] via 14.1.1.2, 00:00:18, Serial1/1
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial1/1
发现2.2.2.0/24还是没改过来,这是因为R1没有给R4传递这条路由,所以R4只能通过ospf学习这条路由,为什么R1不给R4传递这条路由了呢?R1通过rip学习到metric值为1,R4把这条路由重发布给rip,metric值也为1,所以R1负载均衡,由于水平分割机制,R1不会把这条路由在传回给R2和R4。
那么就把这条路由在R4上重发布给rip时的metric值增大即可。
R4(config)#access-list 2 permit 2.2.2.0
R4(config)#route-map c1 permit 10
R4(config-route-map)#match ip address 2
R4(config-route-map)#set metric 3
R4(config-route-map)#exi
R4(config)#route-map c1 permit 20
R4(config-route-map)#exi
R4(config)#router rip
R4(config-router)#redistribute ospf 100 metric 1 route-map c1
R4(config-router)#en
R4#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Serial1/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 14.1.1.2, 00:00:05, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/2] via 14.1.1.2, 00:00:05, Serial1/1
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/65] via 34.1.1.1, 00:15:06, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
C 4.4.4.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/128] via 34.1.1.1, 00:15:06, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
R 12.1.1.0 [120/1] via 14.1.1.2, 00:00:06, Serial1/1
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial1/1
此时R4路由表正常
看R2的路由表
R2#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/128] via 23.1.1.2, 01:35:33, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 23.1.1.2, 00:17:55, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/65] via 23.1.1.2, 01:33:29, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
O 4.4.4.0 [110/129] via 23.1.1.2, 01:33:19, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
14.0.0.0/24 is subnetted, 1 subnets
O E2 14.1.1.0 [110/20] via 23.1.1.2, 01:31:33, Serial1/1
同样的问题,R2学习AD值为110的ospf路由,不学习AD值为120的rip路由
R2(config)#access-list 1 permit 1.1.1.0
R2(config)#access-list 1 permit 14.1.1.0
R2(config)#router ospf 100
R2(config-router)#distance 121 94.4.4.4 0.0.0.0 1
R2(config-router)#en
R2#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
O 34.1.1.0 [110/128] via 23.1.1.2, 00:00:26, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 12.1.1.1, 00:00:11, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
O 3.3.3.0 [110/65] via 23.1.1.2, 00:00:26, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
O 4.4.4.0 [110/129] via 23.1.1.2, 00:00:26, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.1.1.0 is directly connected, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
14.0.0.0/24 is subnetted, 1 subnets
R 14.1.1.0 [120/1] via 12.1.1.1, 00:00:12, Serial1/0
此时R4的路由已经正常
看R1的路由表
R1#sho ip route
34.0.0.0/24 is subnetted, 1 subnets
R 34.1.1.0 [120/1] via 14.1.1.1, 00:00:17, Serial1/0
[120/1] via 12.1.1.2, 00:00:14, Serial1/1
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/1] via 12.1.1.2, 00:00:14, Serial1/1
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 14.1.1.1, 00:00:17, Serial1/0
[120/1] via 12.1.1.2, 00:00:14, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/1] via 14.1.1.1, 00:00:17, Serial1/0
[120/1] via 12.1.1.2, 00:00:14, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
R 23.1.1.0 [120/1] via 14.1.1.1, 00:00:18, Serial1/0
[120/1] via 12.1.1.2, 00:00:15, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/1
14.0.0.0/24 is subnetted, 1 subnets
C 14.1.1.0 is directly connected, Serial1/0
34.1.1.0/24、4.4.4.0/24、23.1.1.0/24这三条路由,在R2和R4重发布进rip时种子度量值都为1,故R1负载均衡,只需在R2上把重发布进rip的34.1.1.0/24、4.4.4.0/24路由的metric增大,把R4上重发布进rip的23.1.1.0/24路由metric值增大即可。这里使用offset-list
R1(config)#access-list 1 permit 34.1.1.0
R1(config)#access-list 1 permit 4.4.4.0
R1(config)#access-list 2 permit 23.1.1.0
R1(config)#router rip
R1(config-router)#offset-list 1 in 3 serial 1/1
R1(config-router)#offset-list 2 in 3 serial 1/0
R1#sho ip route rip
34.0.0.0/24 is subnetted, 1 subnets
R 34.1.1.0 [120/1] via 14.1.1.1, 00:00:07, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
R 2.2.2.0 [120/1] via 12.1.1.2, 00:00:17, Serial1/1
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 14.1.1.1, 00:00:07, Serial1/0
[120/1] via 12.1.1.2, 00:00:17, Serial1/1
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/1] via 14.1.1.1, 00:00:07, Serial1/0
23.0.0.0/24 is subnetted, 1 subnets
R 23.1.1.0 [120/1] via 12.1.1.2, 00:00:17, Serial1/1
此时R1路由表正常
看R3路由表
R3#sho ip route ospf
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 34.1.1.2, 00:35:22, Serial1/1
[110/20] via 23.1.1.1, 00:14:11, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 34.1.1.2, 00:20:33, Serial1/1
[110/20] via 23.1.1.1, 01:49:49, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
O 4.4.4.0 [110/65] via 34.1.1.2, 01:50:47, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
O E2 12.1.1.0 [110/20] via 34.1.1.2, 00:35:22, Serial1/1
[110/20] via 23.1.1.1, 01:49:49, Serial1/0
14.0.0.0/24 is subnetted, 1 subnets
O E2 14.1.1.0 [110/20] via 34.1.1.2, 01:49:00, Serial1/1
[110/20] via 23.1.1.1, 00:14:11, Serial1/0
R3到达2.2.2.0/24、12.1.1.0/24、14.1.1.0/24网段负载均衡,因为R2和R4重发布进ospf时AD值都为110,故负载均衡,但ospf中一个路由器学习到两条相同AD值的路由,不能通过修改AD值来优选路由
我们知道OE1类型优于OE2,metric值小优,故我们在R2上把2.2.2.0/24、12.1.1.0/24重发布时类型改为OE1,R3优选R2的这两条路由,把14.1.1.0/24metric值改为21,R3优选R4的这条路由
R2(config)#access-list 2 permit 2.2.2.0
R2(config)#access-list 2 permit 12.1.1.0
R2(config)#access-list 3 permit 14.1.1.0
R2(config)#route-map c2 permit 10
R2(config-route-map)#match ip address 2
R2(config-route-map)#set metric-type type-1
R2(config-route-map)#exi
R2(config)#route-map c2 permit 20
R2(config-route-map)#match ip address 3
R2(config-route-map)#set metric 21
R2(config-route-map)#exi
R2(config)#route-map c2 permit 30
R2(config-route-map)#exi
R2(config)#router ospf 100
R2(config-router)#redistribute rip subnets route-map c2
此时R3的路由表已经正常
R3#sho ip route ospf
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 34.1.1.2, 00:57:22, Serial1/1
[110/20] via 23.1.1.1, 00:36:10, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E1 2.2.2.0 [110/84] via 23.1.1.1, 00:00:06, Serial1/0
4.0.0.0/24 is subnetted, 1 subnets
O 4.4.4.0 [110/65] via 34.1.1.2, 02:12:46, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
O E1 12.1.1.0 [110/84] via 23.1.1.1, 00:00:06, Serial1/0
14.0.0.0/24 is subnetted, 1 subnets
O E2 14.1.1.0 [110/20] via 34.1.1.2, 02:10:59, Serial1/1
总结:
1,路由器优选路由时先比较AD值,再比较metric值;
2,先解决重发布路由器上的路由回馈及选路不加问题;
3,解决其他路由器选路不佳问题。
4,抓取路由,改变指定更新源的AD值
5,抓取路由,重发布时使用route-map改变其metric值
6,抓取路由,使用offset-list增大in或out方向的metric值