rip协议的使用
路由信息协议(RIP)
常见的协议的分类:动态的和静态的。
内部网关协议(igp):rip igrp eigrp ospf is-is
外部网关协议(egp):bgp4
RIP是一种分布式的基于距离向量的路由选择协议,是因特网的标准协议,其最大的优点就是简单。RIP协议将“距离”定义为:从一路由器到直接连接的网络的距离定义为1。从一路由器到非直接连接的网络的距离定义为每经过一个路由器则距离加1。“距离”也成为“跳数”。RIP允许一条路径最多只能包含15个路由器,因此,距离等于16时即为不可达。
rip协议使用udp的520端口进行消息的交流。
rip的特点:
1:周期更新时间30s
2:采用的是广播(v1 版本 广播 ,v2版本 224.0.0.9)
3:适合较小规模的网络
4:属于等代价的负载均衡 默认的最大的条数为4条,最大的为6条。
5:计算metric值(最大的条数为16跳)
解决路由环路的机制
a,最大跳 16
b,水平分割
c,路由毒化
d,毒性逆转
e,触发更新 抑制计时器180
案例一:
[R1]dis cu
interface Ethernet1
loopback
ip address 192.168.1.1 255.255.255.0
!
interface Serial0
clock DTECLK1
link-protocol ppp
ip address 192.168.4.1 255.255.255.0
!
interface Serial1
link-protocol ppp
ip address 192.168.5.1 255.255.255.0
!
rip
network 192.168.5.0
network 192.168.4.0
network 192.168.1.0
!
quit
!
return
[R1]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/24 Direct 0 0 192.168.1.1 Ethernet1
192.168.1.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.2.0/24 RIP 100 1 192.168.4.2 Serial0
192.168.3.0/24 RIP 100 1 192.168.5.2 Serial1
192.168.4.0/24 Direct 0 0 192.168.4.2 Serial0
192.168.4.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.4.2/32 Direct 0 0 192.168.4.2 Serial0
192.168.5.0/24 Direct 0 0 192.168.5.2 Serial1
192.168.5.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.5.2/32 Direct 0 0 192.168.5.2 Serial1
[r2]dis cu
interface Ethernet1
loopback
ip address 192.168.2.1 255.255.255.0
!
interface Serial0
link-protocol ppp
ip address 192.168.4.2 255.255.255.0
!
interface Serial1
link-protocol ppp
!
rip
network 192.168.4.0
network 192.168.2.0
!
quit
!
return
[r2]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/24 RIP 100 1 192.168.4.1 Serial0
192.168.2.0/24 Direct 0 0 192.168.2.1 Ethernet1
192.168.2.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.3.0/24 RIP 100 2 192.168.4.1 Serial0
192.168.4.0/24 Direct 0 0 192.168.4.1 Serial0
192.168.4.1/32 Direct 0 0 192.168.4.1 Serial0
192.168.4.2/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.5.0/24 RIP 100 1 192.168.4.1 Serial0
[r3]dis cu
interface Ethernet1
loopback
ip address 192.168.3.1 255.255.255.0
!
interface Serial0
link-protocol ppp
!
interface Serial1
clock DTECLK1
link-protocol ppp
ip address 192.168.5.2 255.255.255.0
!
quit
rip
network 192.168.5.0
network 192.168.3.0
!
quit
!
return
[r3]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/24 RIP 100 1 192.168.5.1 Serial1
192.168.2.0/24 RIP 100 2 192.168.5.1 Serial1
192.168.3.0/24 Direct 0 0 192.168.3.1 Ethernet1
192.168.3.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.4.0/24 RIP 100 1 192.168.5.1 Serial1
192.168.5.0/24 Direct 0 0 192.168.5.1 Serial1
192.168.5.1/32 Direct 0 0 192.168.5.1 Serial1
192.168.5.2/32 Direct 0 0 127.0.0.1 LoopBack0
[r3] info center console
[r3]debu rip p
Enable Rip packet debugging functions
[r3]
RIP:receive Response from 192.168.5.1(Serial1)
Packet:vers 1, cmd Response, length 64
dest 192.168.4.0,Metric 1
dest 192.168.2.0,Metric 2
dest 192.168.1.0,Metric 1 对于从r1路由器s1发布出去的路由直连的增加metric1,非直连的增加metric2
RIP: send from 192.168.3.1 to 255.255.255.255(Ethernet1)
Packet:vers 1, cmd Response, length 84
dest 192.168.4.0,Metric 2
dest 192.168.2.0,Metric 3
dest 192.168.1.0,Metric 2
dest 192.168.5.0,Metric 1
RIP: send from 192.168.5.2 to 255.255.255.255(Serial1)
Packet:vers 1, cmd Response, length 24
dest 192.168.3.0,Metric 1 在这里我们看到从s1上面只发布了3.0网段的信息,说明从r1学习到的路由并没有重新的反回给r1,水平分割起了作用。
RIP:receive Response from 192.168.5.1(Serial1)
Packet:vers 1, cmd Response, length 64
dest 192.168.4.0,Metric 1
dest 192.168.2.0,Metric 2
dest 192.168.1.0,Metric 1
RIP: send from 192.168.3.1 to 255.255.255.255(Ethernet1)
Packet:vers 1, cmd Response, length 84
dest 192.168.4.0,Metric 2
dest 192.168.2.0,Metric 3
dest 192.168.1.0,Metric 2
dest 192.168.5.0,Metric 1
RIP: send from 192.168.5.2 to 255.255.255.255(Serial1)
Packet:vers 1, cmd Response, length 24
dest 192.168.3.0,Metric 1undo debugging all
All debugging has been disabled
案例二:
简介:定长的连续的子网掩码
[r1]dis cu
Now create configuration...
Current configuration
!
version 1.74
sysname r1
undo pos-server addr-switch
firewall enable
aaa-enable
aaa accounting-scheme optional
!
controller e1 0
!
interface Aux0
async mode flow
link-protocol ppp
!
interface Ethernet0
!
interface Ethernet1
loopback
ip address 192.168.1.1 255.255.255.224
!
interface Serial0
clock DTECLK1
link-protocol ppp
ip address 192.168.1.33 255.255.255.224
!
interface Serial1
link-protocol ppp
ip address 192.168.1.65 255.255.255.224
!
interface Async0
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async1
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async2
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async3
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async4
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async5
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async6
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async7
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async8
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async9
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async10
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async11
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async12
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async13
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async14
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async15
physical-mode async
async mode protocol
link-protocol ppp
!
quit
rip
network 192.168.1.0
!
quit
!
return
[r1]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/27 Direct 0 0 192.168.1.1 Ethernet1
192.168.1.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.32/27 Direct 0 0 192.168.1.34 Serial0
192.168.1.33/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.34/32 Direct 0 0 192.168.1.34 Serial0
192.168.1.64/27 Direct 0 0 192.168.1.66 Serial1
192.168.1.65/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.66/32 Direct 0 0 192.168.1.66 Serial1
192.168.1.96/27 RIP 100 1 192.168.1.34 Serial0
192.168.1.128/27 RIP 100 1 192.168.1.66 Serial1
[r2]dis cu
Now create configuration...
Current configuration
!
version 1.74
sysname r2
undo pos-server addr-switch
firewall enable
aaa-enable
aaa accounting-scheme optional
!
interface Aux0
async mode flow
link-protocol ppp
!
interface Ethernet0
!
interface Ethernet1
loopback
ip address 192.168.1.97 255.255.255.224
!
interface Serial0
link-protocol ppp
ip address 192.168.1.34 255.255.255.224
!
interface Serial1
link-protocol ppp
!
interface Async0
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async1
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async2
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async3
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async4
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async5
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async6
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async7
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async8
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async9
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async10
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async11
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async12
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async13
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async14
physical-mode async
async mode protocol
link-protocol ppp
!
interface Async15
physical-mode async
async mode protocol
link-protocol ppp
!
quit
rip
network 192.168.1.0
!
quit
!
return
[r2]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/27 RIP 100 1 192.168.1.33 Serial0
192.168.1.32/27 Direct 0 0 192.168.1.33 Serial0
192.168.1.33/32 Direct 0 0 192.168.1.33 Serial0
192.168.1.34/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.64/27 RIP 100 1 192.168.1.33 Serial0
192.168.1.96/27 Direct 0 0 192.168.1.97 Ethernet1
192.168.1.97/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.128/27 RIP 100 2 192.168.1.33 Serial0
[r3]dis cu
Now create configuration...
Current configuration
!
version 1.74
sysname r3
firewall enable
aaa-enable
aaa accounting-scheme optional
!
interface Aux0
async mode flow
link-protocol ppp
!
interface Ethernet0
!
interface Ethernet1
loopback
ip address 192.168.1.129 255.255.255.224
!
interface Serial0
link-protocol ppp
!
interface Serial1
clock DTECLK1
link-protocol ppp
ip address 192.168.1.66 255.255.255.224
!
quit
rip
network 192.168.1.0
!
quit
!
return
[r3]dis ip rou
Routing Tables:
Destination/Mask Proto Pref Metric Nexthop Interface
127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.0/27 RIP 100 1 192.168.1.65 Serial1
192.168.1.32/27 RIP 100 1 192.168.1.65 Serial1
192.168.1.64/27 Direct 0 0 192.168.1.65 Serial1
192.168.1.65/32 Direct 0 0 192.168.1.65 Serial1
192.168.1.66/32 Direct 0 0 127.0.0.1 LoopBack0
192.168.1.96/27 RIP 100 2 192.168.1.65 Serial1
192.168.1.128/27 Direct 0 0 192.168.1.129 Ethernet1
192.168.1.129/32 Direct 0 0 127.0.0.1 LoopBack0
说明:这是一个简单的rip协议的实验,仅供参考使用!!!!
对于广域网接口,后面配置的需要进行复位才可以!!!
欢迎加入郑州阳仔的网络工程师自由交流群--132444800(请注明自己的身份,就说是51cto的博友)