CCNA的RIP路由学习
rip(routing infomation protocol,路由信息协议) ,是一个纯粹的距离矢量路由选择协议,RIP每隔30s就将自己完整的路由选择表从所有激活的接口上送出。RIP只将跳计数作为判断到达远程网络最佳路径的依据,并且在默认情况下允许最大的跳计数为15.也就是说,16就被认为不可达的。
RIP版本1只使用有类的路由选择,即网络中的所有设备都必须使用相同的子网掩码。这是因为RIP版本1在发送更新数据中不携带子网掩码信息。RIP版本2提供了前缀路由选择信息,并可以在路由更新中传送子网掩码信息,这就是无类的路由选择。
避免路由环路的四种办法:
1,水平分割,只朝一个方向广播数据更新。
2,最大跳数,设置最大跳数为15,则16跳就表示为不可达。
3,路由中毒,当网络出现故障时,通告网络的跳计数为16不可达。
4,保持关闭,保持关闭就是当有接口关闭并打开的时候,路由信息立即更新,然后又关闭,路由信息又立即更新。保持关闭可以阻止太频繁的路由改变。
RIP 例子
router0 路由器配置:
Building configuration... Current configuration : 637 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
ip address 172.16.1.254 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.12.1 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
network 172.16.0.0
network 192.168.12.0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
login
!
!
!
end
router1 的配置
Building configuration... Current configuration : bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/
ip address 192.168.23.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/
ip address 192.168.12.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
network 192.168.12.0
network 192.168.23.0
!
ip classless
!
ip flow-export version
!
!
!
!
!
!
!
line con
!
line aux
!
line vty
login
!
!
!
end
router2的配置
Building configuration... Current configuration : bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
no ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface Loopback1
ip address 172.16.31.1 255.255.255.0
!
interface Loopback2
ip address 172.16.32.1 255.255.255.0
!
interface Loopback3
ip address 172.16.33.1 255.255.255.0
!
interface FastEthernet0/
ip address 192.168.23.3 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
router rip
network 172.16.0.0
network 192.168.23.0
!
ip classless
!
ip flow-export version
!
!
!
!
!
!
!
line con
!
line aux
!
line vty
login
!
!
!
end
测试:在Router1上ping172.16.1.254
Router#ping 172.16.1.254 Type escape sequence to abort.
Sending , -byte ICMP Echos to 172.16.1.254, timeout is seconds:
..!U!
Success rate is percent (/), round-trip min/avg/max = // ms
Router1上的路由表为:
Router#sh ip rou
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ [/] via 192.168.12.1, ::, FastEthernet0/
[/] via 192.168.23.3, ::, FastEthernet0/
C 192.168.12.0/ is directly connected, FastEthernet0/
C 192.168.23.0/ is directly connected, FastEthernet0/
到172.16.0.0的有两个路由,可以从192.168.12.1走,也可以从192.168.23.3 走,从而ping 172.16.1.254 可以从两条路线走,从而导致时通时坏。
Router0上的路由表为:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ is subnetted, subnets
C 172.16.1.0 is directly connected, FastEthernet0/
C 192.168.12.0/ is directly connected, FastEthernet0/
R 192.168.23.0/ [/] via 192.168.12.2, ::, FastEthernet0/
Router0上只有到达192.168.23.0的路由,没有学习到到Router3上的172.16.31.1,172.16.32.1,172.16.33.1 的路由。
Router2上的路由表为:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ is subnetted, subnets
C 172.16.31.0 is directly connected, Loopback1
C 172.16.32.0 is directly connected, Loopback2
C 172.16.33.0 is directly connected, Loopback3
R 192.168.12.0/ [/] via 192.168.23.2, ::, FastEthernet0/
C 192.168.23.0/ is directly connected, FastEthernet0/
Router2 也没有学习到Router0上的172.16.1.254 的网络。
Router1 上的sh ip protocol如下
Router#sh ip protocols
Routing Protocol is "rip"
Sending updates every seconds, next due in seconds
Invalid after seconds, hold down , flushed after
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version , receive any version
Interface Send Recv Triggered RIP Key-chain
FastEthernet0/
FastEthernet0/
Automatic network summarization is in effect
Maximum path:
Routing for Networks:
192.168.12.0
192.168.23.0
Passive Interface(s):
Routing Information Sources:
Gateway Distance Last Update
192.168.12.1 ::
192.168.23.3 ::
Distance: (default is )
在Router1 上的RIP通过如下:
Router#debug ip rip
RIP protocol debugging is on
Router#RIP: received v1 update from 192.168.12.1 on FastEthernet0/
172.16.0.0 in hops
RIP: received v1 update from 192.168.23.3 on FastEthernet0/
172.16.0.0 in hops
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (192.168.12.2)
RIP: build update entries
network 192.168.23.0 metric
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (192.168.23.2)
RIP: build update entries
network 192.168.12.0 metric
在Router1上的通过为 收到router0 的172.16.0.0 的通告,也收到Router2的172.16.0.0 的通告。
在Router0 上的RIP通告如下:
Router#debug ip rip
RIP protocol debugging is on
Router#RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (172.16.1.254)
RIP: build update entries
network 192.168.12.0 metric
network 192.168.23.0 metric
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (192.168.12.1)
RIP: build update entries
network 172.16.0.0 metric
RIP: received v1 update from 192.168.12.2 on FastEthernet0/
192.168.23.0 in hops
Router0 上的通过是发送172.16.0.0通告给Router1 路由器。根本没有收到172.16.31.0,172.16.32.0,172.16.33.0 的通告。为什么没有收到路由通告呢?原因是由于172.16.1.254是带有子网掩码的子类,被汇总为172.16.0.0/16了,要让网络正常,只能使用RIP v2.并且必须关闭自动汇总。
自动汇总:
RIP是一个有类路由协议,会在主类网络边界产生自动汇总。
什么是边界呢?当路由器从一个接口向外发送更新包时,如果要传送的路由与路由传播接口IP地址所在网络的主网络号不同,则路由器要把传送的路由汇总成主类网络在发送出去。
在Router0上有直连网络192.168.12.0/24和172.16.1.0/24两个主类网络的边界。
RIPv2将172.16.1.0/24这个网络宣告出去时,通过Fa0/1口。而Fa0/1的IP地址所在的主网络是192.168.12.0/24。
172.16.1.0/24与192.168.12.0/24不是同一个主网络号,所以172.16.1.0/24会汇总为172.16.0.0/16发送给Router1。
Router#debug ip rip
RIP protocol debugging is on
Router#RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (172.16.1.254)
RIP: build update entries
network 192.168.12.0 metric
network 192.168.23.0 metric
RIP: sending v1 update to 255.255.255.255 via FastEthernet0/ (192.168.12.1)
RIP: build update entries
network 172.16.0.0 metric 1
RIP: received v1 update from 192.168.12.2 on FastEthernet0/
如何让该网络保持正常通信,必须在每个路由器上的rip协议下关闭自动汇总。
命令为:
Router(config)#router rip
Router(config-router)#version 2 Router(config-router)#no auto-summary
重新配置后的路由器的路由表为:
router0 :
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ is subnetted, subnets
C 172.16.1.0 is directly connected, FastEthernet0/
R 172.16.31.0 [/] via 192.168.12.2, ::, FastEthernet0/
R 172.16.32.0 [/] via 192.168.12.2, ::, FastEthernet0/
R 172.16.33.0 [/] via 192.168.12.2, ::, FastEthernet0/
C 192.168.12.0/ is directly connected, FastEthernet0/
R 192.168.23.0/ [/] via 192.168.12.2, ::, FastEthernet0/
router1:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ is variably subnetted, subnets, masks
R 172.16.0.0/ [/] via 192.168.12.1, ::, FastEthernet0/
[/] via 192.168.23.3, ::, FastEthernet0/
R 172.16.1.0/ [/] via 192.168.12.1, ::, FastEthernet0/
R 172.16.31.0/ [/] via 192.168.23.3, ::, FastEthernet0/
R 172.16.32.0/ [/] via 192.168.23.3, ::, FastEthernet0/
R 172.16.33.0/ [/] via 192.168.23.3, ::, FastEthernet0/
C 192.168.12.0/ is directly connected, FastEthernet0/
C 192.168.23.0/ is directly connected, FastEthernet0/
router2:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 172.16.0.0/ is subnetted, subnets
R 172.16.1.0 [/] via 192.168.23.2, ::, FastEthernet0/
C 172.16.31.0 is directly connected, Loopback1
C 172.16.32.0 is directly connected, Loopback2
C 172.16.33.0 is directly connected, Loopback3
R 192.168.12.0/ [/] via 192.168.23.2, ::, FastEthernet0/
C 192.168.23.0/ is directly connected, FastEthernet0/
此时的router1 的路由通告如下:
Router#debug ip rip
RIP protocol debugging is on
Router#RIP: received v2 update from 192.168.12.1 on FastEthernet0/
172.16.1.0/ via 0.0.0.0 in hops
RIP: received v2 update from 192.168.23.3 on FastEthernet0/
172.16.31.0/ via 0.0.0.0 in hops
172.16.32.0/ via 0.0.0.0 in hops
172.16.33.0/ via 0.0.0.0 in hops
RIP: received v2 update from 192.168.12.1 on FastEthernet0/
172.16.1.0/ via 0.0.0.0 in hops
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/ (192.168.12.2)
RIP: build update entries
172.16.31.0/ via 0.0.0.0, metric , tag
172.16.32.0/ via 0.0.0.0, metric , tag
172.16.33.0/ via 0.0.0.0, metric , tag
192.168.23.0/ via 0.0.0.0, metric , tag
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/ (192.168.23.2)
RIP: build update entries
172.16.1.0/ via 0.0.0.0, metric , tag
192.168.12.0/ via 0.0.0.0, metric , tag
router0 的RIP通告为
Router#debug ip rip
RIP protocol debugging is on
Router#RIP: received v2 update from 192.168.12.2 on FastEthernet0/
172.16.31.0/ via 0.0.0.0 in hops
172.16.32.0/ via 0.0.0.0 in hops
172.16.33.0/ via 0.0.0.0 in hops
192.168.23.0/ via 0.0.0.0 in hops
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/ (172.16.1.254)
RIP: build update entries
172.16.31.0/ via 0.0.0.0, metric , tag
172.16.32.0/ via 0.0.0.0, metric , tag
172.16.33.0/ via 0.0.0.0, metric , tag
192.168.12.0/ via 0.0.0.0, metric , tag
192.168.23.0/ via 0.0.0.0, metric , tag
RIP: sending v2 update to 224.0.0.9 via FastEthernet0/ (192.168.12.1)
RIP: build update entries
172.16.1.0/ via 0.0.0.0, metric , tag
注:ip cef 和 no ip cef 的区别是,开启ip cef 可以直接在cef表查找是否有对应项,关闭ip cef则需要通过ARP协议查找mac地址是否对应。
什么时候需要开启自动汇总?而什么时候需要关闭自动汇总?
总结:在RIPv1有类路由的情况下开启自动汇总,RIPv1不支持VLSM,不携带子网掩码,在RIPv2中有子网存在的网络中需要关闭自动汇总,VLSM也必须关闭自动汇总,在路由的两端都出现相同网段的子网。
举个例子:R0:192.168.1.1/26, 192.168.30.1 R1:192.168.30.2/24 ,192.16.1.2/24 R2:192.16.1.3 ,192.168.1.252/26.
关闭自动汇总则能学习到完整的路由,没有关闭自动汇总则被汇总为192.168.1.0/24的网络,则中间路由学习到192.168.1.0 的路由指向为两个路由器。这样会导致路由环路,时断时好。路由表如下:
没关自动汇总路由:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 C 192.16.10.0/ is directly connected, FastEthernet0/
R 192.168.1.0/ [/] via 192.168.30.2, ::, FastEthernet0/
[/] via 192.16.10.2, ::, FastEthernet0/
R 192.168.2.0/ [/] via 192.16.10.2, ::, FastEthernet0/
C 192.168.30.0/ is directly connected, FastEthernet0/
关闭之后的自动汇总:
Router#sh 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 , N2 - OSPF NSSA external type
E1 - OSPF external type , E2 - OSPF external type , E - EGP
i - IS-IS, L1 - IS-IS level-, L2 - IS-IS level-, 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 C 192.16.10.0/ is directly connected, FastEthernet0/
192.168.1.0/ is subnetted, subnets
R 192.168.1.192 [/] via 192.16.10.2, ::, FastEthernet0/
R 192.168.2.0/ [/] via 192.16.10.2, ::, FastEthernet0/
C 192.168.30.0/ is directly connected, FastEthernet0/
关闭之后网络恢复正常。
有一个问题,就是r0有192.168.1.0的网段,中间连接r1,在连接一个r2,r2上也有192.168.1.0的网段,如果在r1与192.168.1.0的网段通信则会一会掉一会好。
最后补充一下:
子网就是比如A类的10.10.10.1子网掩码是255.255.255.0.(10.10.10.0/24或者/16)
B类的172.16.110.0/24这样。
C类 192.168.1.1/26.(自动汇总为192.168.1.0/24)
CCNA的RIP路由学习的更多相关文章
- (转)示例化讲解RIP路由更新机制
目录(?)[+] 以下内容摘自最新上市的“四大金刚”图书之一<Cisco路由器配置与管理完全手册>(第二版)(其它三本分别为<Cisco交换机配置与管理完全手册>(第二 ...
- 路由器配置——RIP路由
一.实验目的:用rip路由实现全网互通 二.拓扑图: 三.具体步骤配置 (1)R1路由器配置 Router>enable --进入特权模式Router#configure terminal ...
- 简述RIP路由协议和OSPF路由协议的相同点和不同点。
路由协议分为静态路由协议和动态路由协议.动态路由协议有很多种,如RIP.OSPF.EIGRP等. 1.RIP(路由信息协议)是路由器生产商之间使用的第一个开放标准.RIP有两个版本:RIPv1和RIP ...
- Linux 路由 学习笔记 之一 相关的数据结构
http://blog.csdn.net/lickylin/article/details/38326719 从现在开始学习路由相关的代码,在分析代码之前, 我们还是先分析数据结构,把数据结构之间的关 ...
- 路由器基本配置实验,静态路由和动态RIP路由
实验涉及命令以及知识补充 连线 PC和交换机FastEtherNet接口 交换机和路由器FastEtherNet接口 路由器和路由器Serial接口 serial是串行口,一般用于连接设备,不能连接电 ...
- Rip路由实验
以上是实验要求和实验拓扑图 (实验拓扑自己重新连线) 1.在R1-R4,4台路由器上各设置一个回环口 2.略 3.在四个路由器上配置rip(rip的基本命令) #rip 1 #version 2 #u ...
- 关于AngularJs中的路由学习总结
AngularJs中的路由,应用比较广泛,主要是允许我们通过不同的url访问不同的内容,可实现多视图的单页web应用.下面看看具体怎么使用. 关于路由 通常我们的URL形式为http://jtjds ...
- Vue路由学习心得
GoodBoy and GoodGirl~进来了就看完点个赞再离开,写了这么多也不容易的~ 一.介绍 1.概念:路由其实就是指向的意思,当我们点击home按钮时,页面中就要显示home的内容,点击l ...
- vue-router路由学习总结
vue路由 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
随机推荐
- web自己主动保存表单
note:当中部分源代码来源网络 所用的框架:jquery 实现的功能: 1.自己主动保存表单 2.页面刷新的时候把自己主动保存的值赋值给表单元素 思路: 1.表单值改变的时候自己主动触发函数.保存表 ...
- VK Cup 2012 Qualification Round 1 C. Cd and pwd commands 模拟
C. Cd and pwd commands Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- [CoffeeScript] Level 4 Arrays, Objects, Iterations -- Ex
Coffee on the Range Create an array with numbers 1 until 10 using the inclusive (two dot) range synt ...
- 如何避免MVC Model First 设计时添加的DataAnnotation被覆盖掉
结合多方资料做一系统,发现Code First中所有代码要自己写,无法自动生成(暂时没有找到方法,有知道的大能,给指点一下,好像在NuGet中有一个插件可以直接从数据库中生成Code First所需类 ...
- mysql数据类型区别
create table t1(c1 float(10,2), c3 decimal(10,2)); insert into t1 values(1234567.23, 1234567.23,1234 ...
- shell 笔记
shell 笔记 通配符 没有 '.' [Aa] 表示 A 或者 a ? 表示任意字符 * 表示任意字符串 IFS data='name, sex, rollno, location' oldIFS= ...
- C语言中的各种修饰符
C允许同时使用多于一个的修饰符,这就使得可以创建一下各种类型: int board[8][8];//int数组的数组 int **ptr;//指向int的指针的指针 int *risk[10];//具 ...
- Golang学习 - errors 包
------------------------------------------------------------ Go 语言使用 error 类型来返回函数执行过程中遇到的错误,如果返回的 e ...
- The Socket API, Part 3: Concurrent Servers
转:http://www.linuxforu.com/2011/10/socket-api-part-3-concurrent-servers/ By Pankaj Tanwar on October ...
- Handler发送消息
Handler发送消息小结 字数283 阅读210 评论0 喜欢1 obtainMessage()得到一个Message对象. 创建一个Message然后发送是这么写的: Message msg = ...