Redistribute配置实例

先说一下相关知识
 
重分发的概念
重分发是将一种路由选择协议获悉的网络告知另一种路由选择协议,以便网络中每台工作站能到达其他的任何一台工作站。对重新分配影响最大的协议特性是:度量;管理距离;从无类别协议向有类别协议重新分配。
 
度量
路由重分发时,必须给重分发而来的路由指定的度量值被称为默认度量值或种子度量值,它是在重分发期间定义的。关于度量值,还不是很清楚,摘抄一份资料如下:
 
1、在向RIP、EIGRP区域重分发路由的时候,必须指定度量值,或通过“default-metric”命令设置默认种度量值;
2、RIP、EIGRP默认种子度量值为无限大,只有重分发静态(包括直连和默认)特殊,可以不用指定种子度量值;
3、在“redistribute”命令中用参数“metric”指定的种子度量值优先于在路由模式下使用“default-metric”命令设定的默认的种子度量值;
4、当重新分配来自多个源点的路由时,命令“default-metric”显得十分有用;
5、因为EIGRP度量相对复杂,所以在重分发时,需要分别指定带宽、延迟、可靠性、负载以及MTU参数的值;
6、EIGRP能够识别内部路由和外部路由,默认情况下,内部路由的管理距离是90,外部路由的管理距离是170
7、关键字subnets仅当向OSPF重新分配路由时使用,它指明子网的细节将被重新分配;没有它,仅重新分配主网地址。
 
管理距离
确定首选路径:首选路由源;管理距离越小,协议的可信度越高
可能会带来的问题:非最佳路由;路由下环路;收敛慢等
 
 
下面是配置实例。
 
实验环境
Dynamips模拟器
Cisco IOS Software, 3700 Software (C3745-ADVIPSERVICESK9-M), Version 12.4(4)T, RELEASE SOFTWARE (fc1)
 
拓扑结构
如下图所示,R1与R2之间使用静态路由(默认路由),R1与R3之间使用RIP,R1与R4之间使用EIGRP,R1与R5之间使用OSPF。
 
Redistribute配置实例
 
 
操作过程如下
 
一、基本配置
按网络拓扑图设置端口IP,确保相邻端口之间能够相互ping通。
配置略。
 
 
二、路由配置
为方便测试,在配置动态路由时,使用no auto-summary命令关闭自动汇总(OSPF默认是不汇总的,也没有no auto-summary命令)。
 
R1,各端口分别按要求配置不同的路由
R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.2.2
R1(config)#router rip 
R1(config-router)#net 192.168.3.0
R1(config-router)#version 2
R1(config-router)#no auto-summary
R1(config-router)#exit
R1(config)#router eigrp 100
R1(config-router)#net 192.168.4.0
R1(config-router)#no auto-summary
R1(config-router)#exit
R1(config)#router ospf 1
R1(config-router)#net 192.168.5.0 0.0.0.255 area 0
R1(config-router)#exit
------------------------------------
R2,配置默认路由
R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.1
------------------------------------
R3,配置RIP
R3(config)#router rip 
R3(config-router)#net 192.168.3.0
R3(config-router)#net 3.3.3.0
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#exit
------------------------------------
R4,配置EIGRP
R4(config)#router eigrp 100
R4(config-router)#net 192.168.4.0
*Mar  1 00:17:48.019: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 100: Neighbor 192.168.4.1 (FastEthernet1/4) is up: new adjacency
R4(config-router)#net 4.4.4.0
R4(config-router)#no auto-summary
*Mar  1 01:08:34.239: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 100: Neighbor 192.168.4.1 (FastEthernet1/4) is resync: summary configured
R4(config-router)#exit
------------------------------------
R5,配置OSPF
R5(config)#router ospf 1
R5(config-router)#net 192.168.5.0 0.0.0.255 area 0
*Mar  1 00:19:05.547: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.5.1 on FastEthernet1/5 from LOADING to FULL, Loading Done
R5(config-router)#net 5.5.5.0 0.0.0.255 area 0
R5(config-router)#exit
------------------------------------
配置好路由后,因为R1处于网络边界,且同时运行了不同的路由协议,所在R1可以学习到整个网络的完整路由。show ip route命令查看R1路由,如下:
 
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
 
     2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [1/0] via 192.168.2.2
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/1] via 192.168.3.3, 00:00:28, FastEthernet1/3
     4.0.0.0/24 is subnetted, 1 subnets
D       4.4.4.0 [90/156160] via 192.168.4.4, 00:02:16, FastEthernet1/4
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.168.5.5, 01:09:20, FastEthernet1/5
C    192.168.4.0/24 is directly connected, FastEthernet1/4
C    192.168.5.0/24 is directly connected, FastEthernet1/5
C    192.168.2.0/24 is directly connected, FastEthernet1/2
C    192.168.3.0/24 is directly connected, FastEthernet1/3
------------------------------------
R2、R3、R4、R5之间,由于路由协议的不相同,当前情况下是相互看不到的。需要在R1上进行重分发。
 
 
三、配置重分发
重分发的配置是在边界路由器,即R1上设置的。
 
1、静态路由与RIP的重分发
R1(config)#router rip
R1(config-router)#redistribute connected  !把直连路由分布到路由协议中
R1(config-router)#redistribute static  !将静态路由重分发到RIP中
------------------------------------
配置结束后,在R2仍然只能看默认路由,但R3上已经可以看到到达R2的路由了,并且R2 ping 3.3.3.3,R3 ping 2.2.2.2都是通的。
另外,配置结束后,在R3上也可以看到到达192.168.4.0、192.168.5.0网段的路由,但此时的R3并不能ping通R4、R5,是因为R1没有对ospf、eigrp进行重分发。
 
查看此时R2和R3的路由表及ping测试:
R2#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
C       2.2.2.0 is directly connected, Loopback0
C    192.168.2.0/24 is directly connected, FastEthernet1/2
S*   0.0.0.0/0 [1/0] via 192.168.2.1
------------------------------------
R2#ping 3.3.3.3
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/34/64 ms
------------------------------------
R3#sh ip route
……
R    2.0.0.0/8 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
R    192.168.4.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
R    192.168.5.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
R    192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
C    192.168.3.0/24 is directly connected, FastEthernet1/3
------------------------------------
R3#ping 2.2.2.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/39/64 ms
------------------------------------
 
2、静态路由与EIGRP的重分发
R1(config)#router eigrp 100
R1(config-router)#redistribute connected
R1(config-router)#redistribute static !将静态路由重分发到eigrp中
------------------------------------
配置结束后,在R2上仍然只能看默认路由,但R4上已经可以看见到达R2的路由了,并且R2 ping 4.4.4.4,R4 ping 2.2.2.2都是通的。
 
查看此时R4的路由表:
R4#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
D EX    2.2.2.0 [170/30720] via 192.168.4.1, 01:14:10, FastEthernet1/4
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    192.168.4.0/24 is directly connected, FastEthernet1/4
D EX 192.168.5.0/24 [170/30720] via 192.168.4.1, 01:14:10, FastEthernet1/4
D EX 192.168.2.0/24 [170/30720] via 192.168.4.1, 01:14:10, FastEthernet1/4
D EX 192.168.3.0/24 [170/30720] via 192.168.4.1, 01:14:10, FastEthernet1/4
------------------------------------
 
3、静态路由与OSPF的重分发
R1(config)#router ospf 1
R1(config-router)#redistribute connected 
% Only classful networks will be redistributed
R1(config-router)#redistribute static subnets  !将静态路由重分发到ospf中
% Only classful networks will be redistributed
------------------------------------
注意,把路由重分发到OSPF中,后面要写subnets选项,否则除主类以外的子网不能被重新分发进路由表。以上命令中,如果不加subnets字段,R2可ping 通5.5.5.5,但R5 ping 不通2.2.2.2(R5可以ping通R2)。
 
配置结束后,在R2上仍然只能看静态路由(默认路由),但R5上已经可以看见到达R2的路由了,并且R2 ping 5.5.5.5,R5 ping 2.2.2.2都是通的。
 
查看此时R5的路由表:
R5#sh ip route
……
     5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
O E2 192.168.4.0/24 [110/20] via 192.168.5.1, 01:14:13, FastEthernet1/5
C    192.168.5.0/24 is directly connected, FastEthernet1/5
O E2 192.168.2.0/24 [110/20] via 192.168.5.1, 01:14:13, FastEthernet1/5
O E2 192.168.3.0/24 [110/20] via 192.168.5.1, 01:14:13, FastEthernet1/5
------------------------------------
 
4、RIP与EIGRP重分发
R1(config)#router rip 
R1(config-router)#redistribute eigrp 100 metric 10  !将eigrp重分发到rip
R1(config-router)#exit
R1(config)#router eigrp 100
R1(config-router)#redistribute rip metric 10000 100 255 1 1500  !将rip重分发到eigrp
------------------------------------
注意,将eigrp重分发到rip时,必须指明度量,即命令redistribute eigrp 100 metric 10,如果没有“metric 10”,则R3看不到R4的路由。
重分发路由协议到eigrp时,也必须指度量,并且要指明带宽等,命令“metric 10000 100 255 1 1500”中的五个参数一定要正确,否则会报错“% Incomplete command”。这五个参数中,唯一可以修改的是带宽值,可根据实际情况设置,其他4个参数不能改。五个参数如下:
Bandwidth in kilobytes=10000
Delay in 10s of microseconds=100
Reliability=255(maximum)
Loading=1(minimum)
Maximum Transmission Unit=1500
 
配置完成后,在R3、R4上可以看到彼此之间的路由了。
 
查看此时R3及R4的路由表:
R3#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 192.168.3.1, 00:00:23, FastEthernet1/3
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     4.0.0.0/24 is subnetted, 1 subnets
R       4.4.4.0 [120/10] via 192.168.3.1, 00:00:23, FastEthernet1/3
R    192.168.4.0/24 [120/1] via 192.168.3.1, 00:00:23, FastEthernet1/3
R    192.168.5.0/24 [120/1] via 192.168.3.1, 00:00:23, FastEthernet1/3
R    192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:23, FastEthernet1/3
C    192.168.3.0/24 is directly connected, FastEthernet1/3
------------------------------------
R4#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
D EX    2.2.2.0 [170/30720] via 192.168.4.1, 01:32:39, FastEthernet1/4
     3.0.0.0/24 is subnetted, 1 subnets
D EX    3.3.3.0 [170/284160] via 192.168.4.1, 00:02:12, FastEthernet1/4
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
C    192.168.4.0/24 is directly connected, FastEthernet1/4
D EX 192.168.5.0/24 [170/30720] via 192.168.4.1, 01:32:39, FastEthernet1/4
D EX 192.168.2.0/24 [170/30720] via 192.168.4.1, 01:32:39, FastEthernet1/4
D EX 192.168.3.0/24 [170/30720] via 192.168.4.1, 01:32:39, FastEthernet1/4
------------------------------------
 
 
5、RIP与OSPF重分发
R1(config)#router rip
R1(config-router)#redistribute ospf 1 metric 10
R1(config-router)#exit
R1(config)#router ospf 1
R1(config-router)#redistribute rip metric 200 subnets 
------------------------------------
注意,将ospf重分发到rip时,必须指明度量,即命令redistribute ospf 1 metric 10。 
将rip重分发到ospf时,也必须指度量,并且使用subnets选项,否则R5看不到R3的路由。subnets选项可以确保RIP网络中的无类子网路由能够正确的被发布。
 
配置完成后,在R3、R5上可以看到彼此之间的路由了。
 
R3#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     4.0.0.0/24 is subnetted, 1 subnets
R       4.4.4.0 [120/10] via 192.168.3.1, 00:00:08, FastEthernet1/3
     5.0.0.0/32 is subnetted, 1 subnets
R       5.5.5.5 [120/10] via 192.168.3.1, 00:00:08, FastEthernet1/3
R    192.168.4.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
R    192.168.5.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
R    192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:08, FastEthernet1/3
C    192.168.3.0/24 is directly connected, FastEthernet1/3
------------------------------------
R5#sh ip route
……
     3.0.0.0/24 is subnetted, 1 subnets
O E2    3.3.3.0 [110/200] via 192.168.5.1, 00:00:43, FastEthernet1/5
     5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
O E2 192.168.4.0/24 [110/20] via 192.168.5.1, 01:38:10, FastEthernet1/5
C    192.168.5.0/24 is directly connected, FastEthernet1/5
O E2 192.168.2.0/24 [110/20] via 192.168.5.1, 01:38:10, FastEthernet1/5
O E2 192.168.3.0/24 [110/20] via 192.168.5.1, 01:38:10, FastEthernet1/5
------------------------------------
 
 
6、EIGRP与OSPF重分发
R1(config)#router eigrp 100
R1(config-router)#redistribute ospf 1 metric 10000 100 255 1 1500
R1(config-router)#exit
R1(config)#router ospf 1
R1(config-router)#redistribute eigrp 100 metric 200 subnets 
------------------------------------
注意,如前面所说,将路由向eigrp重分发时,带宽、延迟等五个参数一定要正确。将路由向ospf重分发时,后面要写subnets选项。
 
配置完成后,在R4、R5上可以看到彼此之间的路由了。
R4#sh ip route
……
     2.0.0.0/24 is subnetted, 1 subnets
D EX    2.2.2.0 [170/30720] via 192.168.4.1, 01:51:06, FastEthernet1/4
     3.0.0.0/24 is subnetted, 1 subnets
D EX    3.3.3.0 [170/284160] via 192.168.4.1, 00:20:39, FastEthernet1/4
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
D EX    5.5.5.5 [170/284160] via 192.168.4.1, 00:03:03, FastEthernet1/4
C    192.168.4.0/24 is directly connected, FastEthernet1/4
D EX 192.168.5.0/24 [170/30720] via 192.168.4.1, 01:51:06, FastEthernet1/4
D EX 192.168.2.0/24 [170/30720] via 192.168.4.1, 01:51:06, FastEthernet1/4
D EX 192.168.3.0/24 [170/30720] via 192.168.4.1, 01:51:06, FastEthernet1/4
------------------------------------
R5#sh ip route
……
     3.0.0.0/24 is subnetted, 1 subnets
O E2    3.3.3.0 [110/200] via 192.168.5.1, 00:07:21, FastEthernet1/5
     4.0.0.0/24 is subnetted, 1 subnets
O E2    4.4.4.0 [110/200] via 192.168.5.1, 00:02:27, FastEthernet1/5
     5.0.0.0/24 is subnetted, 1 subnets
C       5.5.5.0 is directly connected, Loopback0
O E2 192.168.4.0/24 [110/20] via 192.168.5.1, 01:50:19, FastEthernet1/5
C    192.168.5.0/24 is directly connected, FastEthernet1/5
O E2 192.168.2.0/24 [110/20] via 192.168.5.1, 01:50:19, FastEthernet1/5
O E2 192.168.3.0/24 [110/20] via 192.168.5.1, 01:50:19, FastEthernet1/5
------------------------------------
 
至此,整个网络实现互通。
 

本文转自Sunshyfangtian 51CTO博客,原文链接:http://blog.51cto.com/sunshyfangtian/846572,如需转载请自行联系原作者

上一篇:树莓派上面安装配置teamviewer


下一篇:Asp.net MVC 示例项目"Suteki.Shop"分析之---Controller