RIP传递默认路由的5种方法

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中水平分割默认开启

传递默认路由方法3:手工建立一条静态默认路由,在RIP进程用NETWORK宣告出去
R1(config)#ip route 0.0.0.0 0.0.0.0 null 0
R1(config)#router rip
R1(config-router)#net 0.0.0.0
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:14, 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上路由表:
  1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/1] via 12.0.0.1, 00:00:05, 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:06, 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:06, Serial2/1 //默认路由被传递
如果把创建静态路由改成这样R1(config)#ip route 0.0.0.0 0.0.0.0 s2/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:14, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1  //默认路由没了。
总结:
手工创建默认路由在RIP进程中宣告0.0.0.0以后,虽然可以传递默认路由但是它把那些没宣告的网络也宣告了出去导致其他路由器有了这些网络的路由信息。
注意:手工创建的默认路由如果跟出接口和下一跳地址,默认路由不会从这个接口和能到达下一跳地址的那个接口传递出去(和方法3要注意的一样)


传递默认路由方法4:先手工创建默认路由到NULL0,然后在想传送默认路由的接口下手工汇总默认路由 ip summary-address rip 0.0.0.0 0.0.0.0
R1(config)#ip route 0.0.0.0 0.0.0.0 nu 0
R1(config)#int s2/1
R1(config-if)#ip summary-address rip 0.0.0.0 0.0.0.0
看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:12, 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
     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:12, Serial2/1 //默认路由有了
但是没有了11.11.11.0这条路由了。
如果在R1上做这样的操作R1(config)#ip route 0.0.0.0 0.0.0.0 s2/1
R2的路由表:
     23.0.0.0/24 is subnetted, 1 subnets
C       23.0.0.0 is directly connected, Serial2/2
     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:06, Serial2/1  //默认路由还在

总结:
用手工汇总的方法传递默认路由,具有方向性,即在哪个接口做的汇总就会从那个接口传递默认路由,它不管创建的默认路由接口和下一跳地址(注意和方法2和3的对比说明手工汇总由于水平分割)但是如果这样会造成路由环路所以建议手工创建到默认路由接口写null0,会在这个接口抑制掉了除了静态路由以外的明细路由(也要注意对比这句所说的

传递默认路由方法5:
ip default-network
R1(config)#ip default-network 1.0.0.0
看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:18, 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:17, 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:17, Serial2/1  //默认路由出现
如果命令R1(config)#ip default-network 1.1.1.0
在看路由表:
     1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       1.1.1.0/24 is directly connected, Loopback0
S       1.0.0.0/8 [1/0] via 1.1.1.0   //会多出现一条静态路由
     23.0.0.0/24 is subnetted, 1 subnets
R       23.0.0.0 [120/1] via 12.0.0.2, 00:00:09, 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:10, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1  //没有默认路由的出现说明必须是主类不能是明细    
R1(config)#ip default-network 23.0.0.0

     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:14, 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:07, Serial2/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.0.0.0 is directly connected, Serial2/1

如果default-network的是一个R1中没有的网络什么效果也没有。

总结:
ip default-network 后面必须跟主类网络,如果不跟主类,跟的是一个子网或者是地址的话,回自动生成一条静态路由。
主类路由是前提:
1:直连路由可以发送
2:路由表中没有的话不发送
3:学到的路由可以发,但是不会从学到这条路由的接口发出去,如果是从其他协议学到的发出去的metric为16,其他路由器不收.
4:创建的主类静态路由也可以发出去,如果静态路由跟了出接口和下一跳地址的他不会从这个接口和能到达下一跳地址的接口传递

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值