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 ...
随机推荐
- javascript中字符串格式转化成json对象记录
什么是JSON JSON(JavaScript Object Notation)是一种优美的JavaScript对象创建方法.JSON也是一种轻量级数据交换格式.JSON非常易于人阅读与编写,同时利于 ...
- hdu4085 Peach Blossom Spring 斯坦纳树,状态dp
(1)集合中元素表示(1<<i), i从0开始 (2)注意dp[i][ss] = min(dp[i][ss], dp[i][rr | s[i]] + dp[i][(ss ^ rr) | s ...
- NGUI ERROR:UnityException: Sprite is not rectangle-packed. TextureRect is invalid.解决
在使用Ngui 3.4.9的时候,使用“Unity 2D Sprite”控件的时候,出现了UnityException: Sprite is not rectangle-packed. Texture ...
- JavaScript实现http地址自动检测并添加URL链接
一.天生我材必有用 给http字符自动添加URL链接是比较常见的一项功能.举两个我最近常用到的自动检测http://地址并添加链接的例子吧,首先是QQ邮箱,在使用QQ邮箱时,如果输入了URL地址(ht ...
- 推荐几个可以与PhoneGap很好搭配的UI框架
- xui.js:可以被视作是jquery在phonegap上的替代品,挺好用的- jq.mobi:同上,不过体积比xui.js要大,一般还是用xui.js- jq.ui:jq.mobi配套的UI框架 ...
- HTML目录
1. 表格标记 2. HTML常用标记 3. 博客园添加访问人数统计 4. 如何快速掌握CSS(各种CSS工具) 5. HTTP协议状态码详解(HTTP Status Code)(转)
- Linux 混杂设备、外部中断和输入子系统
混杂设备也是一种字符设备,主设备号固定为10.相对于普通字符设备驱动,它不需要自己去生成设备文件. 1.声明使用的头文件 #include <linux/miscdevice.h> 2.定 ...
- Docker 选项和命令
选项 -D=true|false 使用 debug 模式.默认为 false. -H, --host=[unix:///var/run/docker.sock]: tcp://[host:port]来 ...
- Python笔记(二)
在昨天学习Python之后,感觉它的的确确挺简洁,也挺容易学习.在昨天的学习中我们了解到了Python中while循环语句以及if...else语句的使用,while语句的使用格式是这样的:while ...
- Tika
1.解析图片 @Test public void test1Image() throws IOException, SAXException, TikaException{ String filePa ...