RIP路由协议基本配置

Target:

   掌握在路由器上如何配置RIP路由协议。

实验原理:

RIP(Routing Information Protocols,路由信息协议)是应用较早、使用较普遍的IGP(Interior Gateway Protocol,内部网关协议),适用于小型同类网络,是典型的距离矢量(distance-vector)协议。

RIP协议以跳数做为衡量路径开销的,RIP协议里规定最大跳数为15。

RIP在构造路由表时会使用到3种计时器:更新计时器、无效计时器、刷新计时器。它让每台路由器周期性地向每个相邻的邻居发送完整的路由表。路由表包括每个网络或子网的信息,以及与之相关的度量值。

实验设备:

路由器 2台

实验拓扑图:

   151037459.png


Step:


第一步:配置两台路由器的主机名、接口IP地址

RSR20#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

RSR20(config)#hostname RouterA

RouterA(config)#

RouterA(config)#interface fastEthernet 0/0

RouterA(config-if)#ip address 192.168.1.1 255.255.255.0

RouterA(config-if)#no shutdown

RouterA(config-if)#exit

RouterA(config)#

RouterA(config)#interface loopback 0

RouterA(config-if)#Aug 15 23:46:32 RouterA %7:%LINE PROTOCOL CHANGE: Interface Loopback 0, changed state to UP

RouterA(config-if)#ip address 172.16.1.1 255.255.255.0

RouterA(config-if)#exit

RouterA(config)#

RouterA(config)#interface loopback 1

RouterA(config-if)#Aug 15 23:47:00 RouterA %7:%LINE PROTOCOL CHANGE: Interface Loopback 1, changed state to UP

RouterA(config-if)#ip address 172.16.2.1 255.255.255.0

RouterA(config-if)#exit

RSR20#configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

RSR20(config)#hostname RouterB

RouterB(config)#

RouterB(config)#interface fastEthernet 0/0

RouterB(config-if)#ip address 192.168.1.2 255.255.255.0

RouterB(config-if)#no shutdown

RouterB(config-if)#exit

RouterB(config)#

RouterB(config)#interface loopback 0

RouterB(config-if)#Aug 8 21:00:00 RouterB %7:%LINE PROTOCOL CHANGE: Interface Loopback 0, changed state to UP

RouterB(config-if)#ip address 10.1.1.1 255.255.255.0

RouterB(config-if)#exit

RouterB(config)#

RouterB(config)#interface loopback 1

RouterB(config-if)#Aug 8 21:00:28 RouterB %7:%LINE PROTOCOL CHANGE: Interface Loopback 1, changed state to UP

RouterB(config-if)#ip address 10.2.2.1 255.255.255.0

RouterB(config-if)#exit

第二步:在两台路由器上配置RIP路由协议及协议的版本

RouterA(config)#router rip

RouterA(config-router)#network 192.168.1.0

RouterA(config-router)#version 2

RouterA(config-router)#network 172.16.1.0

RouterA(config-router)#exit

RouterB(config)#router rip

RouterB(config-router)#version 2

RouterB(config-router)#network 192.168.1.0

RouterB(config-router)#network 10.0.0.0

RouterB(config-router)#exit

第三步:查看RIP配置信息,路由表

RouterA#show ip route

Codes: C - connected, S - static, R - RIP B - BGP

O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

R 10.0.0.0/8 [120/1] via 192.168.1.2, 00:00:17, FastEthernet 0/0

C 172.16.1.0/24 is directly connected, Loopback 0

C 172.16.1.1/32 is local host.

C 172.16.2.0/24 is directly connected, Loopback 1

C 172.16.2.1/32 is local host.

C 192.168.1.0/24 is directly connected, FastEthernet 0/0

C 192.168.1.1/32 is local host.

RouterA#

Routing Protocol is "rip"

Sending updates every 30 seconds, next due in 21 seconds

Invalid after 180 seconds, flushed 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 1, receive any version

Interface Send Recv Key-chain

FastEthernet 0/0 1 1 2

Loopback 0 1 1 2

Loopback 1 1 1 2

Routing for Networks:

172.16.0.0

192.168.1.0

Distance: (default is 120)

RouterA#

RouterB#show ip route

Codes: C - connected, S - static, R - RIP B - BGP

O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

C 10.1.1.0/24 is directly connected, Loopback 0

C 10.1.1.1/32 is local host.

C 10.2.2.0/24 is directly connected, Loopback 1

C 10.2.2.1/32 is local host.

R 172.16.0.0/16 [120/1] via 192.168.1.1, 00:00:12, FastEthernet 0/0

C 192.168.1.0/24 is directly connected, FastEthernet 0/0

C 192.168.1.2/32 is local host.

RouterA#show ip rip database

10.0.0.0/8 auto-summary

10.0.0.0/8

[1] via 192.168.1.2 FastEthernet 0/0 00:09

172.16.0.0/16 auto-summary

172.16.1.0/24

[1] directly connected, Loopback 0

172.16.2.0/24

[1] directly connected, Loopback 1

192.168.1.0/24 auto-summary

192.168.1.0/24

[1] directly connected, FastEthernet 0/0

RouterA#show ip rip interface

FastEthernet 0/0 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

192.168.1.1/24

FastEthernet 0/1 is down, line protocol is down

RIP is not enabled on this interface

Null 0 is up, line protocol is up

RIP is not enabled on this interface

Loopback 0 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

172.16.1.1/24

Loopback 1 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

172.16.2.1/24

RouterB#show ip rip

Routing Protocol is "rip"

Sending updates every 30 seconds, next due in 21 seconds

Invalid after 180 seconds, flushed 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 1, receive any version

Interface Send Recv Key-chain

FastEthernet 0/0 1 1 2

Loopback 0 1 1 2

Loopback 1 1 1 2

Routing for Networks:

10.0.0.0

192.168.1.0

Distance: (default is 120)

RouterB#show ip rip database

10.0.0.0/8 auto-summary

10.1.1.0/24

[1] directly connected, Loopback 0

10.2.2.0/24

[1] directly connected, Loopback 1

172.16.0.0/16 auto-summary

172.16.0.0/16

[1] via 192.168.1.1 FastEthernet 0/0 00:08

192.168.1.0/24 auto-summary

192.168.1.0/24

[1] directly connected, FastEthernet 0/0

RouterB#show ip rip interface

FastEthernet 0/0 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

192.168.1.2/24

FastEthernet 0/1 is down, line protocol is down

RIP is not enabled on this interface

Null 0 is up, line protocol is up

RIP is not enabled on this interface

Loopback 0 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

10.1.1.1/24

Loopback 1 is up, line protocol is up

Routing Protocol: RIP

Receive RIPv1 and RIPv2 packets

Send RIPv1 packets only

Passive interface: Disabled

Split horizon: Enabled

V2 Broadcast: Disabled

Multicast registe: Registed

Interface Summary Rip:

Not Configured

IP interface address:

10.2.2.1/24

第四步:测试网络连通性

RouterA#ping 10.1.1.1

Sending 5, 100-byte ICMP Echoes to 10.1.1.1, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

RouterA#ping 10.2.2.1

Sending 5, 100-byte ICMP Echoes to 10.2.2.1, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/10 ms

RouterB#ping 172.16.1.1

Sending 5, 100-byte ICMP Echoes to 172.16.1.1, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

RouterB#ping 172.16.2.1

Sending 5, 100-byte ICMP Echoes to 172.16.2.1, timeout is 2 seconds:

< press Ctrl+C to break >

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

第五步:用debug命令观察路由器接收和发生路由更新的情况

下面是一个完整的RIP路由器接收更新和发送更新的过程,从中可以看到RouterB接收到了RouterA发送的更新,其中包含一条路由信息172.16.0.0(可以看到水平分割原则的作用),然后刷新了路由表。

RouterB本身发送的更新报文则在Fa0/0、Lo0和Lo1三个端口发出,采用广播的方式,广播地址分别为192.168.1.255,10.1.1.255,10.2.2.255,使用UDP 的520端口。在水平分割的原则下,每个端口发送的路由信息均不相同。

RouterB#debug ip rip

Aug 8 21:06:08 RouterB %7: [RIP] RIP recveived packet, sock=2125 src=192.168.1.1 len=24

Aug 8 21:06:08 RouterB %7: [RIP] Cancel peer remove timer

Aug 8 21:06:08 RouterB %7:[RIP] Peer remove timer shedule...

Aug 8 21:06:08 RouterB %7: route-entry: family 2 ip 172.16.0.0 metric 1

Aug 8 21:06:08 RouterB %7: [RIP] Received version 1 response packet

Aug 8 21:06:08 RouterB %7: [RIP] Translate mask to 16

Aug 8 21:06:08 RouterB %7: [RIP] Old path is: nhop=192.168.1.1 routesrc=192.168.1.1 intf=1

Aug 8 21:06:08 RouterB %7: [RIP] New path is: nhop=192.168.1.1 routesrc=192.168.1.1

Aug 8 21:06:08 RouterB %7: [RIP] [172.16.0.0/16] RIP route refresh!

Aug 8 21:06:08 RouterB %7: [RIP] [172.16.0.0/16] RIP distance apply from 192.168.1.1!

Aug 8 21:06:08 RouterB %7: [RIP] [172.16.0.0/16] ready to refresh kernel...

Aug 8 21:06:08 RouterB %7: [RIP] NSM refresh: IPv4 RIP Route 172.16.0.0/16 distance=120 metric=1 nexthop_num=1 distance=120 nexhop=192.168.1.1 ifindex=1

Aug 8 21:06:08 RouterB %7: [RIP] [172.16.0.0/16] cancel route timer

Aug 8 21:06:08 RouterB %7: [RIP] [172.16.0.0/16] route timer schedule...

Aug 8 21:06:23 RouterB %7: [RIP] Output timer expired to send reponse

Aug 8 21:06:23 RouterB %7: [RIP] Prepare to send BROADCAST response...

Aug 8 21:06:23 RouterB %7: [RIP] Building update entries on FastEthernet 0/0

Aug 8 21:06:23 RouterB %7: network 10.0.0.0 metric 1

Aug 8 21:06:23 RouterB %7: [RIP] Send packet to 192.168.1.255 Port 520 on FastEthernet 0/0

Aug 8 21:06:23 RouterB %7: [RIP] Prepare to send BROADCAST response...

Aug 8 21:06:23 RouterB %7: [RIP] Building update entries on Loopback 0

Aug 8 21:06:23 RouterB %7: network 10.2.2.0 metric 1

Aug 8 21:06:23 RouterB %7: network 172.16.0.0 metric 2

Aug 8 21:06:23 RouterB %7: network 192.168.1.0 metric 1

Aug 8 21:06:23 RouterB %7: [RIP] Send packet to 10.1.1.255 Port 520 on Loopback 0

Aug 8 21:06:23 RouterB %7: [RIP] Prepare to send BROADCAST response...

Aug 8 21:06:23 RouterB %7: [RIP] Building update entries on Loopback 1

Aug 8 21:06:23 RouterB %7: network 10.1.1.0 metric 1

Aug 8 21:06:23 RouterB %7: network 172.16.0.0 metric 2

Aug 8 21:06:23 RouterB %7: network 192.168.1.0 metric 1

Aug 8 21:06:23 RouterB %7: [RIP] Send packet to 10.2.2.255 Port 520 on Loopback 1

Aug 8 21:06:23 RouterB %7: [RIP] Schedule response send timer

【注意事项】

1、配置RIP的Network命令时只支持A、B、C的主网络号,如果写入子网则自动转为主网络号。

2、No auto-summary功能只有在RIPv2支持。

【参考配置】

RouterA#show running-config

Building configuration...

Current configuration : 612 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 20:50:30 CST 2007 -ubu1server)

hostname RouterA

!

interface FastEthernet 0/0

ip address 192.168.1.1 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet 0/1

duplex auto

speed auto

!

interface Loopback 0

ip address 172.16.1.1 255.255.255.0

!

interface Loopback 1

ip address 172.16.2.1 255.255.255.0

!

router rip

network 172.16.0.0

network 192.168.1.0

!

line con 0

line aux 0

line vty 0 4

login

!

end

RouterB#show running-config

Building configuration...

Current configuration : 606 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 20:50:30 CST 2007 -ubu1server)

hostname RouterB

!

interface FastEthernet 0/0

ip address 192.168.1.2 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet 0/1

duplex auto

speed auto

!

interface Loopback 0

ip address 10.1.1.1 255.255.255.0

!

interface Loopback 1

ip address 10.2.2.1 255.255.255.0

!

router rip

network 10.0.0.0

network 192.168.1.0

!

line con 0

line aux 0

line vty 0 4

login

!

end