用Zebra做简单的RIP实验

RIP是应用较早、使用较普遍的IGP,适用于小型同类网络,是典型的距离向量(distance-vector)协 议。RIP通过广播UDP报文来交换路由信息,每30秒发送一次路由信息更新。RIP提供跳跃计数(hop count)作为尺度来衡量路由距离,跳跃计数是一个包到达目标所必须经过的路由器的数目。如果到相同 目标有二个不等速或不同带宽的路由器,但跳跃计数相同,则RIP认为两个路由是等距离的。RIP最多支 持的跳数为15,即在源和目的网间所要经过的最多路由器的数目为15,跳数16表示不可达。RIPv2支持 验证、密钥管理、路由汇总、无类域间路由(CIDR)和变长子网掩码(VLSMs)。

Zebra支持RIPv2,使用ripd程序实现RIP路由功能,但ripd程序需要在zebra程序读取接口信息,所以zebra 一定要在ripd之前启动。由于条件所限,下面的RIP实验是在两台单网卡的magiclinux1.2下做的,所以只是 最简单的演示。

按照上面基本配置的方法初始化第一台机器:

shell_1> cd /usr/local/etc
shell_1> cp zebra.conf.sample zebra.conf
shell_1> cp ripd.conf.sample ripd.conf
shell_1> zebra -d

进入zebra设置IP

shell_1> telnet localhost 2601
Password:
Router> en
Password:
Router# conf t
Router(config)# hostname r1
r1(config)# int eth0
r1(config-if)# ip address 192.168.5.121/24
r1(config-if)# ctrl+z
r1# copy run start

进入第一台机器的rip设置

shell_1> ripd -d
shell_1> telnet localhost 2602
Password:
ripd> en
ripd# conf t
ripd(config)# hostname r1_ripd !改个名字好辨认
r1_ripd(config)# router rip !启动rip
r1_ripd(config-router)# network 192.168.5.0/24 !RIPv1是有类别路由协议,RIPv2是无类别路由协议,Zebra 默认支持RIPv2,指定网络需要子网掩码。

r1的RIP简单配置这样就可用了,下面来检验一下:

r1_ripd# sh ip protocols
Routing Protocol is "rip"
Sending updates every 30 seconds with +/-50%, next due in 3 seconds
Timeout after 180 seconds, garbage collect after 120 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive version 2
Interface Send Recv Key-chain
eth0 2 2
Routing for Networks:
192.168.5.0/24
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
Distance: (default is 120)

我们看到RIP已经起来了,是RIPv2。

r1_ripd# sh ip rip
Codes: R - RIP, C - connected, O - OSPF, B - BGP

Network Next Hop Metric From Time

由于就两个接口直连,没有其它网络,所以sh ip rip看不到什么。

Zebra对log处理可能有些问题,使用log stdout不能显示各种debug信息,所以只能记录到文件,在shell下 用tail命令查看。

r1_ripd# debug rip events
r1_ripd# debug rip packet
r1_ripd(config)# log file /usr/local/etc/ripd.log

然后我们在shell下查看debug信息

shell_1> tail -f /usr/local/etc/ripd.log
--------------------------------8<---------------------------------------
2002/04/28 22:17:44 RIP: update timer fire!
2002/04/28 22:17:44 RIP: SEND UPDATE to eth0 ifindex 2
2002/04/28 22:17:44 RIP: multicast announce on eth0
2002/04/28 22:17:44 RIP: update routes on interface eth0 ifindex 2
2002/04/28 22:18:23 RIP: update timer fire!
2002/04/28 22:18:23 RIP: SEND UPDATE to eth0 ifindex 2
2002/04/28 22:18:23 RIP: multicast announce on eth0
2002/04/28 22:18:23 RIP: update routes on interface eth0 ifindex 2
2002/04/28 22:19:04 RIP: update timer fire!
2002/04/28 22:19:04 RIP: SEND UPDATE to eth0 ifindex 2
2002/04/28 22:19:04 RIP: multicast announce on eth0
2002/04/28 22:19:04 RIP: update routes on interface eth0 ifindex 2
--------------------------------8<---------------------------------------

RIP每隔30秒发送一次更新,在sh ip prot可以看到Sending updates every 30 seconds with +/-50%

第二台机器的设置

前面的初始化和第一台一样,不过这里名字设成r2便于辨认,IP设成了192.168.5.123/24。

进入第二台机器的rip设置

shell_2> ripd -d
shell_2> telnet localhost 2602
Password:
ripd> en
ripd# conf t
ripd(config)# hostname r2_ripd
r2_ripd(config)# router rip
r2_ripd(config-router)# network 192.168.5.0/24

执行完network命令,我们看到第一台机器的tail -f /usr/local/etc/ripd.log输出下面的信息:

--------------------------------8<---------------------------------------
2002/04/28 22:19:15 RIP: RECV packet from 192.168.5.123 port 520 on eth0
2002/04/28 22:19:15 RIP: RECV REQUEST version 2 packet size 24
2002/04/28 22:19:15 RIP: 0.0.0.0/0 -> 0.0.0.0 family 0 tag 0 metric 16
2002/04/28 22:19:15 RIP: update routes to neighbor 192.168.5.123
2002/04/28 22:19:35 RIP: update timer fire!
2002/04/28 22:19:35 RIP: SEND UPDATE to eth0 ifindex 2
2002/04/28 22:19:35 RIP: multicast announce on eth0
2002/04/28 22:19:35 RIP: update routes on interface eth0 ifindex 2
--------------------------------8<---------------------------------------

r1通过UDP广播接收到192.168.5.123的更新包,并且把192.168.5.123设为neighbor。

保存一下配置

r1_ripd# copy run start
Configuration saved to /usr/local/etc/ripd.conf
r2_ripd# copy run start
Configuration saved to /usr/local/etc/ripd.conf

Zebra还支持很多RIP功能,如果Filtering RIP Routes, RIP route-map, RIP Authentication等,有条件有时间 的话可以做更复杂的实验。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值