前几天写过一篇名为《两个网络的联通及静态路由配置》的文章,今天说说用RIP协议实现路由器的动态配置。
RIP(路由信息协议)是Internet中常用的路由协议,采用了距离向量算法,即路由器根据距离选择路由,所以也称为距离向量协议(RIP很牛的,会自己学习的^_^)。在RIP配置中最常用到的命令有:
clear ip route 如:清除所有/某一条rip路由:clear ip route * / clear ip route 10.0.0.0
network {network-number}
router rip 打开路由器的rip路由选择处理进程
show ip protocol
show ip route rip 显示所有RIP学到的路径
下面演示一个路由配置实例:
设计以下网络图:
r1配置如下(其中s0端口ip设为192.168.40.1,e0端口ip设为192.168.10.254):
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0
Router(config-if)#ip address 192.168.40.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial0, changed state to up
%LINK-3-UPDOWN: Interface Serial0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
Router(config-if)#int e0
Router(config-if)#ip address 192.168.10.254 255.255.255.0
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
Router(config-if)#end
Router#write memory
Building configuration...
[OK]
pc1配置如下:
下面配置r2,其中s0端口ip为192.168.40.254,s1端口ip为192.168.50.1,e0端口ip为192.168.20.254。
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0
Router(config-if)#ip addr 192.168.40.254 255.255.255.0
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial0, changed state to up
Router(config-if)#int s1
Router(config-if)#ip addr 192.168.50.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial1, changed state to up
%LINK-3-UPDOWN: Interface Serial1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down
Router(config-if)#int e0
Router(config-if)#ip addr 192.168.20.254 255.255.255.0
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
Router(config-if)#end
Router#wri m
Building configuration...
[OK]
pc2配置如图:
下面配置r3,s0端口ip为192.168.50.254,e0端口ip为192.168.30.254。
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int s0
Router(config-if)#ip addr 192.168.50.254 255.255.255.0
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Serial0, changed state to up
Router(config-if)#in e0
Router(config-if)#ip addr 192.168.30.254 255.255.255.0
Router(config-if)#no shut
%LINK-3-UPDOWN: Interface Ethernet0, changed state to up
Router(config-if)#end
Router#wri m
Building configuration...
[OK]
pc3为:
下面为关键部分,rip的配置(配置后才能实现网络的通信):
进入r1,输入:
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#router rip
Router(config-router)#network 192.168.10.0
Router(config-router)#network 192.168.40.0
Router(config-router)#end
Router#wri m
Building configuration...
[OK]
进入r2,输入:
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#router rip
Router(config-router)#network 192.168.20.0
Router(config-router)#network 192.168.40.0
Router(config-router)#network 192.168.50.0
Router(config-router)#end
Router#wri m
Building configuration...
[OK]
进入r3,输入:
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#router rip
Router(config-router)#network 192.168.50.0
Router(config-router)#network 192.168.30.0
Router(config-router)#end
Router#wri m
Building configuration...
[OK]
好啦,到此就全部配置完了,整个网络中的pc1 、pc2 和 pc3 都能够实现通信了。
注:由于路由器30s刷新一次信息,所以配置完成后要等一会才能ping 通。
若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/ripluyoudongtai.html
2 Response to “用RIP协议实现路由表的动态配置”
By dou on 2008-4-17 20:47:23|
哈哈,这次我会了~~~~·
By Yimi on 2008-4-17 22:55:20| http://www.yimio.cn
晕,都是不认识滴。