LoginSignup
0
0

More than 5 years have passed since last update.

纪念我的第四个CCNA实验 RIP2路由协议

Last updated at Posted at 2018-02-03

背景

我在第二个CCNA实验中完成了静态路由的设置,但是很显然在庞大的网络中光想靠静态路由去完成那么多路由以及交换机的路由导向肯定只有白痴才会那么干。
那么有没有一种算法能够让相互之间相连的路由器能够彼此知道对方的直连信息,整个网络当中的所有直连信息都会被归纳。哪个网段是属于哪个路由器的直连,我要去那个网段我只需要找到那个路由器就行。因为整个网络中所有节点的路由器都做到了信息同步,知根知底了,我要找到那个路由器需要走那条路我当前网关所属的路由器会告诉我。
スクリーンショット 2018-02-03 21.44.07.png
图1

解决方案

需求

当然很早以前网络工程师们便有了这样一个想法。他们也在想,路由和路由之间可以在不设定路由表的情况下ping通路由的直连信息的,所以一个携带目标IP的包只需要找到一个路由器,而且这个路由器的直连网段下有这个包的目标IP地址,那么这个包只要到达这个路由器,就能够找到这个包的目标IP地址。
スクリーンショット 2018-02-03 22.07.31.png
图2

具体解决方案

RIP协议。解释网络中所有节点都公开自己的直连网段,整个网络中所有节点的路由都知道。这样,一个路由器可以学习到它旁边的路由的直连网段。然后它也可以通过它旁边的路由学习到它旁边的旁边的路由的直连网段。这样经过不超过15格路由的传输,一个路由最多可以通过这种击鼓传花的方式学习到距离自己14个路由器之隔的路由的直连网段。并且把这个学习到的隔壁第N(15=>N>=1)个路由的直连信息写到自己的路由表里,对应的next-hop是学习到隔壁第N个路由直连信息的自己的直连下的隔壁IP或者自己的网口。
スクリーンショット 2018-02-03 22.34.41.png
图3

实验

实验需求

我们模拟图3的情景
スクリーンショット 2018-02-03 23.53.07.png
图4

实验步骤

1.分别对router1,router2,router3,router4进行rip配置。

1.配置router3的rip路由协议
Router3(config)#router rip
Router3(config-router)#network 192.168.12.0
Router3(config-router)#network 192.168.8.0
Router3(config-router)#network 192.168.9.0
Router3(config-router)#network 192.168.7.0
Router3(config-router)#version 2
Router3#show running-config | begin rip
router rip
 version 2
 network 192.168.7.0
 network 192.168.8.0
 network 192.168.9.0
 network 192.168.12.0
!
ip classless
2.配置router4的rip路由协议
Router4(config)#router rip
Router4(config-router)#network 192.168.11.0 
Router4(config-router)#network 192.168.10.0
Router4(config-router)#network 192.168.9.0
Router4(config-router)#network 192.168.3.0
Router4(config-router)#version 2
Router4(config-router)#exit
Router4(config)#
Router4#show running-config | begin rip
router rip
 network 192.168.3.0
 network 192.168.9.0
 network 192.168.10.0
 network 192.168.11.0
!
ip classless
3.配置router1的rip路由协议
Router1(config)#router rip
Router1(config-router)#network 192.168.3.0
Router1(config-router)#network 192.168.6.0
Router1(config-router)#network 192.168.2.0
Router1(config-router)#network 192.168.1.0
Router1(config-router)#version 2
Router1(config-router)#exit
Router1(config)#
Router1#show running-config | begin rip
router rip
 version 2
 network 192.168.1.0
 network 192.168.2.0
 network 192.168.3.0
 network 192.168.6.0
!
ip classless
4.配置router2的rip路由协议
Router2(config)#router rip
Router2(config-router)#version 2
Router2(config-router)#network 192.168.7.0
Router2(config-router)#network 192.168.6.0
Router2(config-router)#network 192.168.4.0
Router2(config-router)#network 192.168.5.0
Router2(config-router)#exit
Router2(config)#
Router2#show running-config | begin rip
router rip
 version 2
 network 192.168.4.0
 network 192.168.5.0
 network 192.168.6.0
 network 192.168.7.0
!
ip classless

2.分别查看router1,router2,router3,router4在RIP协议下学习到的路由表

以router4为例

Router4(config)#do show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, 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, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

R    192.168.1.0/24 [120/1] via 192.168.3.1, 00:00:26, Serial2/0
R    192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:26, Serial2/0
C    192.168.3.0/24 is directly connected, Serial2/0
R    192.168.4.0/24 [120/2] via 192.168.9.3, 00:00:01, Serial3/0
                    [120/2] via 192.168.3.1, 00:00:26, Serial2/0
R    192.168.5.0/24 [120/2] via 192.168.3.1, 00:00:26, Serial2/0
                    [120/2] via 192.168.9.3, 00:00:01, Serial3/0
R    192.168.6.0/24 [120/1] via 192.168.3.1, 00:00:26, Serial2/0
R    192.168.7.0/24 [120/1] via 192.168.9.3, 00:00:01, Serial3/0
R    192.168.8.0/24 [120/1] via 192.168.9.3, 00:00:01, Serial3/0
C    192.168.9.0/24 is directly connected, Serial3/0
C    192.168.10.0/24 is directly connected, FastEthernet1/0
C    192.168.11.0/24 is directly connected, FastEthernet0/0
R    192.168.12.0/24 [120/1] via 192.168.9.3, 00:00:01, Serial3/0

我们可以看到Router4的路由表中除了192.168.3.0 192.168.9.0 192.168.10.0 192.168.11.0这四个直连以外,还包括了其余的相邻路由的非己方直连的直连网段信息,这些网段信息都是通过RIP协议学习到,并记录到自己的路由表里。

2.执行ping看能否ping通自己的非直连IP地址

以router4为例

Router4#ping 192.168.5.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.5.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms

Router4#ping 192.168.7.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.7.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/2/3 ms

Router4#ping 192.168.6.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/6/12 ms

Router4#
Router4#ping 192.168.8.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.8.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/12 ms

Router4#ping 192.168.12.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/3 ms

Router4#ping 192.168.6.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.6.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/9 ms

Router4#ping 192.168.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/6/17 ms

可以看到,Router4在没有写入任何静态路由的情况下可以ping通非自己直连的网段了。
至此这个最基本的RIP协议的实验成功

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0