RIP传递默认路由的5种方法
图:关于传递默认路由的实验都是以下这个图
RIP传递默认理由方法1:default-information originate
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Loopback1
ip address 11.11.11.11 255.255.255.0
interface Serial2/1
ip address 12.0.0.1 255.255.255.0
router rip
version 2
network 11.0.0.0
network 12.0.0.0
no auto-summary
R2:
interface Serial2/1
ip address 12.0.0.2 255.255.255.0
interface Serial2/2
ip address 23.0.0.2 255.255.255.0
router rip
version 2
network 12.0.0.0
network 23.0.0.0
no auto-summary
R3:
interface Serial2/1
ip address 23.0.0.3 255.255.255.0
router rip
version 2
network 23.0.0.0
no auto-summar
R1路由表
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 12.0.0.2, 00:00:02, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
C 11.11.11.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R2路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/1] via 12.0.0.1, 00:00:20, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R3的路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/2] via 23.0.0.2, 00:00:20, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
R 12.0.0.0 [120/1] via 23.0.0.2, 00:00:20, Serial2/1
R2#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
没路由不通
在R1上做:
R1(config)#router rip
R1(config-router)#default-information originate //可以加个route-map,也可以直接回车
咱们直接回车看效果
R1路由表
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 12.0.0.2, 00:00:01, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
C 11.11.11.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R2路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/1] via 12.0.0.1, 00:00:19, Serial2/1 //说明明细路由可以发出
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R* 0.0.0.0/0 [120/1] via 12.0.0.1, 00:00:19, Serial2/1 //默认路由出来了
R3路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/2] via 23.0.0.2, 00:00:25, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
R 12.0.0.0 [120/1] via 23.0.0.2, 00:00:25, Serial2/1
R* 0.0.0.0/0 [120/2] via 23.0.0.2, 00:00:25, Serial2/1
R2#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 172/249/360 ms
可以说明默认路由起了效果
在R1上做:
R1(config)#router rip
R1(config-router)#default-information originate route-map QQ //名字随便起
在看R2路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/1] via 12.0.0.1, 00:00:14, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
发现默认路由没有了。
可是当我用route-map QQ匹配1.1.1.0/24的路由后
R1(config)#ip prefix-list 1 per 1.1.1.0/24
R1(config)#route-map QQ
R1(config-route-map)#match ip add prefix-list 1
在看R2的路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/1] via 12.0.0.1, 00:00:03, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R* 0.0.0.0/0 [120/1] via 12.0.0.1, 00:00:03, Serial2/1 //又出来了
总结:
default-information originate 可以向网络传递默认路由,自己路由表中没有默认路由存在,如果后面加了route-map,只有自己路由表中有自己匹配的路由才会向其他路由器发送默认路由,路由条目可以是直连也可以是从lab 学来路由,也可以是静态路由.
方法2:创建手工建立一条默认路由到NULL0口,在进行重分布
在R1上:
R1(config)#ip route 0.0.0.0 0.0.0.0 null 0
R1(config)#router rip
R1(config-router)#redistribute static metric 2 //在RIP中重分布静态路由度量默认是1
(在向RIP区域重分布路由的时候,必须指定度量值,或者通过default-metric命令设置默认种子度量值,因为RIP默认种子度量值为无穷大,只有重分布静态特殊,可以不指定度量值)
现在观察R1路由表:
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
R 23.0.0.0 [120/1] via 12.0.0.2, 00:00:08, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
C 11.11.11.0 is directly connected, Loopback1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
S* 0.0.0.0/0 is directly connected, Null0 //自己手工创建的
R2的路由表:
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/1] via 12.0.0.1, 00:00:11, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
R* 0.0.0.0/0 [120/2] via 12.0.0.1, 00:00:11, Serial2/1 //传递过来的默认路由度量2是进行重分布的时候设置的
R3的路由表:
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
11.0.0.0/24 is subnetted, 1 subnets
R 11.11.11.0 [120/2] via 23.0.0.2, 00:00:06, Serial2/1 //不会抑制掉明细的发送
12.0.0.0/24 is subnetted, 1 subnets
R 12.0.0.0 [120/1] via 23.0.0.2, 00:00:06, Serial2/1
R* 0.0.0.0/0 [120/3] via 23.0.0.2, 00:00:06, Serial2/1 //R3上也一样有默认路由
注意:手工创建的默认路由如果跟出接口和下一跳地址,默认路由不会从这个接口和能到达下一跳地址的那个接口传递出去.因为水平分割的问题。RIP中水平分割默认开启