RIP配置的完美攻略

网络 网络管理
下面我们主要讲解一下RIP配置的具体过程。包括了IP地址配置、RIP配置命令、测试RIP配置正确性等有关内容。

对于RIP协议,大家可能是比较熟悉了。这个协议的使用是非常广泛的。在很多组网中,都会应用这个协议。如果你还不会RIP配置的话,也不用着急,接下来我们就来细致地讲解一下配置过程,保准大家都能学会。

IP地址配置

我们可以使用interface命令进入局部配置模式,然后利用ip address设置接口的IP地址.如下所示.

  1. testBJ#conf t  
  2. Enter configuration commands, one per line. End with CNTL/Z.  
  3. testBJ(config)#interface e0/1  
  4. testBJ(config-if)#ip address 172.16.1.2 255.255.255.0  
  5. testBJ(config-if)# 

为了便于配置和记忆,你还可以给每个端口添加一些描述信息.如下所示,在端口局部配置模式下使用description命令.

  1. testBJ(config-if)#description connect to testSH  
  2. testBJ(config-if)#end  
  3. testBJ# 

有些网络是NBMA(Non-Broadcast MultiAccess,非广播多路访问)的,即网络上不允许广播传送数据.对于这种网络,RIP就不能依赖广播传递路由表了.解决方法有很多,最简单的是指定邻居(neighbor),即指定将路由表发送给某一台特定的路由器.

RIP配置

RIP配置是最容易的.配置它只需要两步操作,首先,指定使用RIP协议,然后,声明所连接的网络号,如下所示.

  1. testBJ(config)#router rip  
  2. testBJ(config-router)#network 172.16.0.0  
  3. testBJ(config-router)#end  
  4. testBJ# 

router rip命令用于指定使用RIP协议,network命令声明网络号,由于RIP是一个有类路由协议,所以不必声明各个子网号.对每一台路由器重复上述操作,一个使用RIP路由的网络就建成了.

测试RIP配置正确性

RIP配置之后,要检查数据是否可以被正确路由.除了可以使用上面提到的连通性测试工具之外,还有以下几个命令:

sh ip route用于检测路由表;

sh ip protocols用于检查路由协议状况;

debug ip rip用于调试RIP协议信息.

使用sh ip route命令显示各台路由器的路由表.

  1. testBJ#sh ip route  
  2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP  
  3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area  
  4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2  
  5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP  
  6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,  
  7. * - candidate default, U - per-user static route, o - ODR  
  8. Gateway of last resort is not set  
  9. 172.16.0.0/24 is subnetted, 4 subnets  
  10. R 172.16.4.0 [120/1] via 172.16.2.2, 00:00:12, Serial1/0  
  11. C 172.16.1.0 is directly connected, Ethernet0/1  
  12. C 172.16.2.0 is directly connected, Serial1/0  
  13. R 172.16.3.0 [120/1] via 172.16.1.3, 00:00:09, Ethernet0/1  
  14. [120/1] via 172.16.2.2, 00:00:22, Serial1/0 

上面显示的是北京路由器的路由信息.字母C开头的是直接相连的网络,有172.16.1.0和172.16.2.0,分别连接在e0/1和s1/0端口上.字母R开头的是RIP协议学习到的路由,有172.16.3.0和172.16.4.0,其中,到172.16.3.0有两条路径供选择,分别经由testSH和testTJ路由器.对比网络拓扑图,可以看出实际情况与设计的完全一致.中括号里的内容是路由项的管理距离和度量值,RIP配置的缺省管理距离是120,到达3、4子网的度量值是1,即经过1个路由器可达.同样的命令在另外两台路由器上运行,结果如下.

  1. testSH#sh ip route  
  2. Gateway of last resort is not set  
  3. 172.16.0.0/24 is subnetted, 4 subnets  
  4. R 172.16.4.0 [120/1] via 172.16.3.2, 00:00:13, Ethernet0/0  
  5. C 172.16.1.0 is directly connected, Ethernet0/1  
  6. R 172.16.2.0 [120/1] via 172.16.1.2, 00:00:11, Ethernet0/1  
  7. [120/1] via 172.16.3.2, 00:00:13, Ethernet0/0  
  8. C 172.16.3.0 is directly connected, Ethernet0/0  
  9. testTJ#sh ip route  
  10. Gateway of last resort is not set  
  11. 172.16.0.0/24 is subnetted, 4 subnets  
  12. C 172.16.4.0 is directly connected, Ethernet0/0  
  13. R 172.16.1.0 [120/1] via 172.16.3.3, 00:00:07, Ethernet0/1  
  14. [120/1] via 172.16.2.3, 00:00:19, Serial1/0  
  15. C 172.16.2.0 is directly connected, Serial1/0  
  16. C 172.16.3.0 is directly connected, Ethernet0/1 

分析上述命令输出时,一定要随时参照拓扑图,离开网络拓扑,上面的信息就没有任何意义.动态路由的灵活性体现在一条链路出现故障,路由算法会自动切换到迂回链路上.例如我们将testBJ和testTJ之间的串行线缆断开,一段时间后,再检查路由表,如下所示.

  1. testBJ#sh ip route  
  2. Gateway of last resort is not set  
  3. 172.16.0.0/24 is subnetted, 3 subnets  
  4. R 172.16.4.0 [120/2] via 172.16.1.3, 00:00:22, Ethernet0/1  
  5. C 172.16.1.0 is directly connected, Ethernet0/1  
  6. R 172.16.3.0 [120/1] via 172.16.1.3, 00:00:22, Ethernet0/1 

我们发现串行链路所在的子网2断开了,到网络172.16.4.0网络的数据包都将绕经testSH路由器.

sh ip protocols命令可以显示当前路由协议的状况,如下所示.

  1. testBJ#sh ip protocols  
  2. Routing Protocol is "rip"  
  3. Sending updates every 30 seconds, next due in 19 seconds  
  4. Invalid after 180 seconds, hold down 180, flushed after 240  
  5. Outgoing update filter list for all interfaces is not set  
  6. Incoming update filter list for all interfaces is not set  
  7. Redistributing: connected, rip  
  8. Default version control: send version 1, receive any version  
  9. Interface Send Recv Key-chain  
  10. Ethernet0/1 1 1 2  
  11. Serial1/0 1 1 2  
  12. Routing for Networks:  
  13. 172.16.0.0  
  14. Routing Information Sources:  
  15. Gateway Distance Last Update  
  16. 172.16.2.2 120 00:00:05  
  17. 172.16.1.3 120 00:00:27  
  18. Distance: (default is 120) 

从命令输出中,可以看出RIP配置,还可以得知与当前路由器交换信息的路由器有testTJ(172.16.2.2)和testSH(172.16.1.3)两台路由器,上次接收路由信息分别在5秒和27秒之前.要了解路由器之间交换路由信息的详情,可以使用debug ip rip命令.如下所示,输入命令后,隔一段时间,控制台上出现接收或者发送RIP广播的信息.

  1. testBJ#debug ip rip  
  2. RIP protocol debugging is on  
  3. testBJ#  
  4. RIP: received v1 update from 172.16.2.2 on Serial1/0  
  5. 172.16.4.0 in 1 hops  
  6. 172.16.3.0 in 1 hops  
  7. RIP: received v1 update from 172.16.1.3 on Ethernet0/1  
  8. 172.16.4.0 in 2 hops  
  9. 172.16.3.0 in 1 hops  
  10. RIP: sending v1 update to 255.255.255.255 via Ethernet0/1 (172.16.1.2)  
  11. subnet 172.16.4.0, metric 2  
  12. subnet 172.16.2.0, metric  
  13. RIP: sending v1 update to 255.255.255.255 via Serial1/0 (172.16.2.3)  
  14. subnet 172.16.1.0, metric 1  
  15. RIP: received v1 update from 172.16.1.3 on Ethernet0/1  
  16. 172.16.4.0 in 2 hops  
  17. 172.16.3.0 in 1 hops  
  18. RIP: received v1 update from 172.16.2.2 on Serial1/0  
  19. 172.16.4.0 in 1 hops  
  20. 172.16.3.0 in 1 hops  
  21. testBJ#no debug all  
  22. All possible debugging has been turned off  
  23. testBJ# 

从上述RIP配置信息中可以得到RIP广播的详情.路由器先是从testTJ收到子网3、4的信息,然后又从testSH收到子网3、4的信息.其中,到子网4走testTJ一跳,走testSH两跳,所以,路由表中反映出来的是经由testTJ到子网4;到子网3的距离都是一跳,所以,路由表中有两条并列的路由.一段时间后,当前路由器的更新计时达到30秒,于是,它在两条链路上广播自身的路由表信息.注意,广播路由更新时,RIP采用了水平分割机制,从一个端口上学得的信息就不在这个端口上进行广播,所以当前路由器testBJ只发送子网172.16.1.0的路由信息.使用no debug all命令结束调试信息的显示.需要注意的是debug命令非常消耗路由器资源,所以不要在通讯繁忙的路由器上使用,否则,路由器就会象死机一样停止反应.

责任编辑:佟健 来源: QQread
相关推荐

2010-08-30 16:46:08

Linux DHCP配

2010-08-30 10:53:10

职场

2010-07-02 14:23:33

Ftp服务默认端口

2010-03-30 14:58:57

手机无线上网设置

2010-08-06 10:55:50

配置RIP路由协议

2010-05-31 10:32:38

面试简历

2010-07-28 22:20:10

RIP路由配置

2010-08-06 09:24:07

RIP路由协议

2015-03-11 09:24:54

RIP动态路由协议loopback

2011-01-21 09:32:57

LinuxSendmail

2010-06-30 14:12:48

2009-03-31 09:22:15

2013-08-12 09:47:41

RIP协议网络协议

2009-10-10 15:54:55

RHEL 4配置Pos

2009-11-06 14:51:14

WCF配置子节点

2010-08-06 13:53:12

RIP协议

2010-05-19 13:44:42

Subversion+

2010-03-30 13:09:12

2010-06-30 12:32:53

2009-12-14 14:32:38

动态路由配置
点赞
收藏

51CTO技术栈公众号