路由信息协议(RIP)
简介
(RIP/RIP2/RIPng:Routing Information Protocol) 作为一种内部网关协议或 IGP(内部网关协议),路由选择协议应用于 AS 系统。连接 AS 系统有专门的协议,其中最早的这样的协议是“EGP”(外部网关协议),目前仍然应用于因特网,这样的协议通常被视为内部 AS 路由选择协议。RIP 主要设计来利用同类技术与大小适度的网络一起工作。因此通过速度变化不大的接线连接,RIP 比较适用于简单的校园网和区域网,但并不适用于复杂网络的情况。 RIP 2 由 RIP 而来,属于 RIP 协议的补充协议,主要用于扩大 RIP 2 信息装载的有用信息的数量,同时增加其安全性能。RIP 2 是一种基于 UDP 的协议。在 RIP2 下,每台主机通过路由选择进程发送和接受来自 UDP 端口520的数据包。RIP协议默认的路由更新周期是30S。 RIP的特点 (1)仅和相邻的路由器交换信息。如果两个路由器之间的通信不经过另外一个路由器,那么这两个路由器是相邻的。RIP协议规定,不相邻的路由器之间不交换信息。 (2)路由器交换的信息是当前本路由器所知道的全部信息。即自己的路由表。 (3)按固定时间交换路由信息,如,每隔30秒,然后路由器根据收到的路由信息更新路由表。 适用 RIP 和 RIP 2 主要适用于 IPv4 网络,而 RIPng 主要适用于 IPv6 网络。本文主要阐述 RIP 及 RIP 2。 RIPng:路由选择信息协议下一代(应用于IPv6) (RIPng:RIP for IPv6)RIPng与RIP 1和 RIP 2 两个版本不兼容。 RIP协议的“距离”也称为“跳数”(hop count),因为每经过一个路由器,跳数就加1。RIP认为好的路由就是它通过的路由器的数目少,即“距离短”。RIP允许一条路径最多只能包含15个路由器。因此“距离”等于16时即相当于不可达。可见RIP只适用于小型互联网。 应用 RIP(Routing information Protocol)是应用较早、使用较普遍的内部网关协议(Interior Gateway Protocol,简称IGP),适用于小型同类网络,是典型的距离向量(distance-vector)协议。文档见RFC1058、 RFC1723。 RIP通过广播UDP报文来交换路由信息,每30秒发送一次路由信息更新。RIP提供跳跃计数(hop count)作为尺度来衡量路由距离,跳跃计数是一个包到达目标所必须经过的路由器的数目。如果到相同目标有二个不等速或不同带宽的路由器,但跳跃计数相同,则RIP认为两个路由是等距离的。RIP最多支持的跳数为15,即在源和目的网间所要经过的最多路由器的数目为15,跳数16表示不可达。网络拓扑图
在拓扑图中两台 cisco 3560G 交换机 ,启用三层路由并且运行 rip 路由协议,用于交换自己的路由表,并学习对方的路由信息,一台 cisco 3560 与 cisco 2950 使用 trunk 端口用于交换vlan 信息,最后整个网络通过 linux nat 服务器与外网通信!
配置交换机
大厦 A 层交换机
- #conf ter
- hostname 1F
- ip routing
- vlan 100
- vlan 101
- vlan 102
- vlan 103
- vlan 104
- vlan 105
- vlan 106
- vlan 107
- vlan 108
- vlan 109
- int fa0/1
- sw mo acc
- sw acc vlan 101
- int fa0/2
- sw mo acc
- sw acc vlan 102
- int fa0/3
- sw mo acc
- sw acc vlan 103
- int fa0/4
- sw mo acc
- sw acc vlan 104
- int fa0/5
- sw mo acc
- sw acc vlan 105
- int fa0/6
- sw mo acc
- sw acc vlan 106
- int fa0/7
- sw mo acc
- sw acc vlan 107
- int fa0/8
- sw mo acc
- sw acc vlan 108
- int fa0/9
- sw mo acc
- sw acc vlan 109
- int fa0/10
- sw mo acc
- sw acc vlan 100
- int vlan 100
- ip add 192.168.50.1 255.255.255.0
- int vlan 101
- ip add 192.168.51.1 255.255.255.0
- int vlan 102
- ip add 192.168.52.1 255.255.255.0
- int vlan 103
- ip add 192.168.53.1 255.255.255.0
- int vlan 104
- ip add 192.168.54.1 255.255.255.0
- int vlan 105
- ip add 192.168.55.1 255.255.255.0
- int vlan 106
- ip add 192.168.56.1 255.255.255.0
- int vlan 107
- ip add 192.168.57.1 255.255.255.0
- int vlan 108
- ip add 192.168.58.1 255.255.255.0
- int vlan 109
- ip add 192.168.59.1 255.255.255.0
- exit
- int g0/1
- no switchport
- ip add 192.168.61.1 255.255.255.0
- exit
- int g0/2
- no switchport
- ip add 192.168.0.2 255.255.255.0
- exit
- router rip
- ver 2
- no auto-summary
- network 192.168.50.0
- network 192.168.51.0
- network 192.168.52.0
- network 192.168.53.0
- network 192.168.54.0
- network 192.168.55.0
- network 192.168.56.0
- network 192.168.57.0
- network 192.168.58.0
- network 192.168.59.0
- exit
大厦 B 层交换机
-
- #conf ter
- hostname 2F
- ip routing
- vlan 10
- vlan 20
- vlan 30
- vlan 40
- vlan 50
- vlan 60
- vlan 70
- vlan 80
- vlan 90
- int fa0/1
- sw mo acc
- sw acc vlan 10
- int fa0/2
- sw mo acc
- sw acc vlan 20
- int fa0/3
- sw mo acc
- sw acc vlan 30
- int fa0/4
- sw mo acc
- sw acc vlan 40
- int fa0/5
- sw mo acc
- sw acc vlan 50
- int fa0/6
- sw mo acc
- sw acc vlan 60
- int fa0/7
- sw mo acc
- sw acc vlan 70
- int fa0/8
- sw mo acc
- sw acc vlan 80
- int fa0/9
- sw mo acc
- sw acc vlan 90
- int fa0/24
- switchport mode trunk
- switchport trunk encapsulation dot1q
- int vlan 10
- ip add 192.168.1.1 255.255.255.0
- int vlan 20
- ip add 192.168.2.1 255.255.255.0
- int vlan 30
- ip add 192.168.3.1 255.255.255.0
- int vlan 40
- ip add 192.168.4.1 255.255.255.0
- int vlan 50
- ip add 192.168.5.1 255.255.255.0
- int vlan 60
- ip add 192.168.6.1 255.255.255.0
- int vlan 70
- ip add 192.168.7.1 255.255.255.0
- int vlan 80
- ip add 192.168.8.1 255.255.255.0
- int vlan 91
- ip add 192.168.9.1 255.255.255.192
- int vlan 92
- ip add 192.168.9.65 255.255.255.192
- int vlan 93
- ip add 192.168.9.129 255.255.255.192
- int vlan 94
- ip add 192.168.9.193 255.255.255.192
- exit
- int g0/1
- no switchport
- ip add 192.168.61.2 255.255.255.0
- exit
- int g0/2
- no switchport
- ip add 192.168.62.1 255.255.255.0
- exit
- router rip
- ver 2
- no auto-summary
- network 192.168.1.0
- network 192.168.2.0
- network 192.168.3.0
- network 192.168.4.0
- network 192.168.5.0
- network 192.168.6.0
- network 192.168.7.0
- network 192.168.8.0
- network 192.168.9.0
- network 192.168.61.0
- network 192.168.62.0
- exit
有用的命令
1 查看路由,注意 R打头的行 R - RIP
- #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 192.168.0.1 to network 0.0.0.0
- 192.168.0.0/30 is subnetted, 1 subnets
- C 192.168.0.0 is directly connected, GigabitEthernet0/2
- R 192.168.1.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.2.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.3.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.4.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.5.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.6.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.7.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.8.0/24 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- 192.168.9.0/26 is subnetted, 4 subnets
- R 192.168.9.0 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.9.64 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.9.128 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- R 192.168.9.192 [120/1] via 192.168.61.2, 00:00:22, GigabitEthernet0/1
- C 192.168.50.0/24 is directly connected, Vlan150
- C 192.168.51.0/24 is directly connected, Vlan151
- C 192.168.52.0/24 is directly connected, Vlan152
- C 192.168.53.0/24 is directly connected, Vlan153
- C 192.168.54.0/24 is directly connected, Vlan154
- C 192.168.55.0/24 is directly connected, Vlan155
- C 192.168.56.0/24 is directly connected, Vlan156
- C 192.168.57.0/24 is directly connected, Vlan157
- C 192.168.58.0/24 is directly connected, Vlan158
- C 192.168.59.0/24 is directly connected, Vlan159
- C 192.168.61.0/24 is directly connected, GigabitEthernet0/1
- S* 0.0.0.0/0 [1/0] via 192.168.0.1
2 显示路由器的协议信息
- #show ip protocols
- Default version control: send version 1, receive any version
- Interface Send Recv Triggered RIP Key-chain
- Ethernet0/0 1 1 2
- Loopback0 1 1 2 //默认接收版本1、2,发送版本1
- Loopback2 1 1 2 //发送为RIPv1,不携带子网掩码
- Default version control: send version 2, receive 2
- Interface Send Recv Triggered RIP Key-chain
- GigabitEthernet0/1 2 2
- Vlan151 2 2 //默认接收版本 2,发送版本2
- Vlan152 2 2
3 显示 rip
- show ip rip database
- 0.0.0.0/0 auto-summary
- 0.0.0.0/0
- [0] via 0.0.0.0, 00:12:44
- 192.168.0.0/30 auto-summary
- 192.168.0.0/30 directly connected, GigabitEthernet0/2
- 192.168.1.0/24 auto-summary
- 192.168.1.0/24
- [1] via 192.168.61.2, 00:00:19, GigabitEthernet0/1
- 192.168.2.0/24 auto-summary
- 192.168.2.0/24
- [1] via 192.168.61.2, 00:00:19, GigabitEthernet0/1
拓展
http://netname.blog.51cto.com/941793/656185
http://baike.baidu.com/view/30530.htm
结束
rip 可以在多个三层交换机或者路由器之间动态更新路由表,而不需要网络管理人员手动添加静态路由信息,这是非常棒的但是它的一些特性决定了, RIP只适用于小型互联网,比如RIP允许一条路径最多只能包含15个路由器 ,当然这对于小企业(比如我们公司)是没有什么障碍的!
结束
更多请: linux 系统运维 37275208 vmware 虚拟化 166682360