diff --git "a/\351\222\237\345\207\244\350\213\261/20240506 \350\267\257\347\224\261\345\231\250rip\345\212\250\346\200\201\350\267\257\347\224\261\347\256\200\345\215\225\351\205\215\347\275\256.md" "b/\351\222\237\345\207\244\350\213\261/20240506 \350\267\257\347\224\261\345\231\250rip\345\212\250\346\200\201\350\267\257\347\224\261\347\256\200\345\215\225\351\205\215\347\275\256.md" new file mode 100644 index 0000000000000000000000000000000000000000..4adabbdae0f8be4866389862c3f9df0b3b518e17 --- /dev/null +++ "b/\351\222\237\345\207\244\350\213\261/20240506 \350\267\257\347\224\261\345\231\250rip\345\212\250\346\200\201\350\267\257\347\224\261\347\256\200\345\215\225\351\205\215\347\275\256.md" @@ -0,0 +1,180 @@ +##### 1、RIP简介 + +RIP(Routing Information protocol) 路由信息协议. +是一种内部网关协议(IGP),是一种动态路由选择协议,用于自治系统(AS)内的路由信息的传递。RIP协议基于距离矢量算法(DistanceVectorAlgorithms),使用“跳数”(即metric)来衡量到达目标地址的路由距离。RIP通过UDP报文进行路由信息交换,使用的端口号为520. + +##### RIP的基本概念 + +定期更新 +邻居 +广播更新 +全路由表更新 +RIP度量值为跳数,最大跳数为15跳,16跳不可达; +RIP更新时间为30s发送路由更新消息,UDP 520端口; +RIP会发送整个路由表信息。 + +RIP包括RIP-v1和RIP-v2两个版本 + +2、RIPV1和RIPV2比较 + + RIPV1 RIPV2 +有类路由协议 无类路由协议 +不支持VLSM 支持VLSM +广播更新255.255.255.255 组播更新224.0.0.9 + + + +3、实验拓扑 + +![img](https://img-blog.csdnimg.cn/20201031122433550.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Fubml0YTIwMTk=,size_16,color_FFFFFF,t_70#pic_center) + +4、准备工作 +R1配置端口IP + +```bash +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#ho R1 +R1(config)# +R1(config)#int g0/1 +R1(config-if)#ip add 192.168.10.254 255.255.255.0 +R1(config-if)#no sh + +R1(config-if)# +R1(config-if)#int g0/0 +R1(config-if)#ip add 10.10.30.1 255.255.255.0 +R1(config-if)#no sh + +R1(config-router)#do show ip interface brief +Interface IP-Address OK? Method Status Protocol +GigabitEthernet0/0 10.10.30.1 YES manual up up +GigabitEthernet0/1 192.168.10.254 YES manual up up +GigabitEthernet0/2 unassigned YES unset administratively down down +Vlan1 unassigned YES unset administratively down down +``` + + + + + +R2配置端口IP + +```bash +Router>enable +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. + +Router(config-if)#ho R2 +R2(config)# + +R2(config)# +R2(config)#in g0/1 +R2(config-if)#ip add 192.168.20.254 255.255.255.0 +R2(config-if)#no sh + +R2(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +R2(config-if)#ex +R2(config)#int g0/0 +R2(config-if)#ip add 10.10.30.2 255.255.255.0 +R2(config-if)#no sh + + +R2(config)#do show ip interface brief +Interface IP-Address OK? Method Status Protocol +GigabitEthernet0/0 10.10.30.2 YES manual up up +GigabitEthernet0/1 192.168.20.254 YES manual up up +GigabitEthernet0/2 unassigned YES unset administratively down down +Vlan1 unassigned YES unset administratively down down +``` + + +5、配置RIP协议 +R1 + +```bash +R1(config)#route rip #开启RIP协议 +R1(config-router)#version 2 #启用RIPv2 +R1(config-router)#network 192.168.10.0 #宣告网段 +R1(config-router)#network 10.10.30.0 #宣告网段 +R1(config-router)#no auto-summary #关闭自动汇总xxxxxxxxxx R1(config)#route rip           #开启RIP协议R1(config-router)#version 2   #启用RIPv2R1(config-router)#network 192.168.10.0   #宣告网段R1(config-router)#network 10.10.30.0     #宣告网段R1(config-router)#no auto-summary       #关闭自动汇总 +``` + +为什么要关闭自动汇总?? + +是因为RIP协议更新时不带子网掩码,路由器会根据IP自动判断汇总给其加上自己汇总后的子网掩码。假如有个网段是30.1.1.0/24,更新时不会带上24,路由器会认为是A类IP,通过自动汇总会把24汇总成8,这个不是我们想要的,所以要关闭自动汇总。 + +R2 + +```bash +R2(config-router)#v 2 +R2(config-router)#network 192.168.20.0 +R2(config-router)#network 10.10.30.0 +R2(config-router)#no auto-summary + + +``` + +6、查看路由表 + +```bash +R2(config)#do show ip route +Codes: L - local, C - connected, S - static, 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 + + 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks + +C 10.10.30.0/24 is directly connected, GigabitEthernet0/0 +L 10.10.30.2/32 is directly connected, GigabitEthernet0/0 +R 192.168.10.0/24 [120/1] via 10.10.30.1, 00:00:21, GigabitEthernet0/0 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/1 +L 192.168.20.254/32 is directly connected, GigabitEthernet0/1 +``` + + +L-本地,C-直连,S-静态,R-RIP,以R开头的就是RIP协议的: + +```bash + R 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks + + +``` + +分析: + +[120/1] 120是度量值,如果我在路由表手工加入一条静态路由,静态路由默认的度量值默认是1,优先级高于120,则优先执行静态路由; +[120/1] 1 是跳数; +00:00:21 是距离下次更新倒计时21秒 +7、验证结果 + +用PC1 PING PC2 + +```bash +C:\>ping 192.168.20.1 + +Pinging 192.168.20.1 with 32 bytes of data: + +Reply from 192.168.20.1: bytes=32 time<1ms TTL=126 +Reply from 192.168.20.1: bytes=32 time<1ms TTL=126 +Reply from 192.168.20.1: bytes=32 time<1ms TTL=126 +Reply from 192.168.20.1: bytes=32 time<1ms TTL=126 + +Ping statistics for 192.168.20.1: + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), +Approximate round trip times in milli-seconds: + Minimum = 0ms, Maximum = 0ms, Average = 0ms +``` +