2022年2022年静态与动态路由配置实例 .pdf
第一部分动态路由配置 (RIP) RIP 命令格式:r2(config)#router ripr2(config-router)#network 12.0.0.0 r2(config-router)#network 193.168.1.0 要求1、R0:2 个 Serial0(2501) ;2、R1:1 个 Serial0、1 个 Ethernet0(805) ;3、R2:1 个 Serial0、1 个 Ethernet0(805) ;4、S1、S2:2950 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 16 页 - - - - - - - - - 一、 R1 配置Routerenable (进入特权模式)Router#config t (进入全局配置模式 ) Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r1 (设置交换机的主机名 ) r1(config)#r1(config)#int s0 (进入 Serail 接口配置模式)r1(config-if)#ip add 11.1.1.1 255.0.0.0 (设置接口的 IP 地址)r1(config-if)#clock rate 64000 (设置同步时钟)%LINK-3-UPDOWN: Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up r1(config-if)#no sh (激活当前接口)r1(config-if)#ex(退回特权模式)r1(config)#int e0r1(config-if)#ip add 192.168.1.1 255.255.255.0r1(config-if)#no sh %LINK-3-UPDOWN: Interface Ethernet0, changed state to up r1(config-if)#exr1(config)#r1(config)#router rip (进入 RIP 协议配置子模式)r1(config-router)#network 11.0.0.0(声明网络 11.0.0.0/8)/这一步“ 11.0.0.0 ”必须与其子网掩码相对应,如上其子网掩码为255.0.0.0r1(config-router)#network 192.168.1.0/这一步“ 192.168.1.0”必须与其子网掩码相对应,如上其子网掩码为255.255.255.0r1(config-router)#exr1(config)#ex r1#sh ip rou (查看路由表信息)Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 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, * - candidate default U - per-user static route Gateway of last resort is not set C 11.0.0.0 is directly connected, Serial0 C 192.168.1.0 is directly connected, Ethernet0 R 12.0.0.0 120/1 via 11.1.1.2, 00:02:25, Serial0 R:表示此项路由是由RIP 协议获取的, C 表示直接相连的网段12.0.0.0:表示目标网段120/1:120 表示 RIP 协议的管理距离默认为120,1 是该路由的度量值,即跳名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 16 页 - - - - - - - - - 数Via:经由的意思11.1.1.2 :表示从当前路由器出发到达目标网的下一跳点的IP 地址00:02:25:表示该条路由产生的时间Serial0:表示该条路由使用的接口测试连通性r1#ping 12.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#r1#sh ip rou /这一步是在其它 router 全部配置完成后操作, 否结果有所不同Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 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, * - candidate default U - per-user static route Gateway of last resort is not set C 11.0.0.0 is directly connected, Serial0 C 192.168.1.0 is directly connected, Ethernet0 R 12.0.0.0 120/1 via 11.1.1.2, 00:08:12, Serial0 R 193.168.1.0 120/2 via 11.1.1.2, 00:09:33, Serial0 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 16 页 - - - - - - - - - 二、 R2 配置Router Router Routeren Router#Router#con t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r2 r2(config)#int s0r2(config-if)#ip add 12.1.1.1 255.0.0.0r2(config-if)#clock rate 64000%LINK-3-UPDOWN: Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up r2(config-if)#no shr2(config-if)#exr2(config)#int e0r2(config-if)#ip add 193.168.1.1 255.255.255.0r2(config-if)#no sh%LINK-3-UPDOWN: Interface Ethernet0, changed state to up r2(config-if)#exr2(config)#r2(config)#router ripr2(config-router)#network 12.0.0.0r2(config-router)#network 193.168.1.0r2(config-router)#exr2(config)#ex r2#r2#sh ip rouCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 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, * - candidate default U - per-user static route Gateway of last resort is not set C 12.0.0.0 is directly connected, Serial0 C 193.168.1.0 is directly connected, Ethernet0 R 11.0.0.0 120/1 via 12.1.1.2, 00:06:29, Serial0 R 192.168.1.0 120/2 via 12.1.1.2, 00:02:22, Serial0 r2# 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 16 页 - - - - - - - - - 三、 R0 配置Router RouterenRouter#con tEnter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r0r0(config)#int s0r0(config-if)#ip add 11.1.1.2 255.0.0.0r0(config-if)#clock rate 64000r0(config-if)#no shr0(config-if)#exr0(config)#int s1r0(config-if)#ip add 12.1.1.2 255.0.0.0r0(config-if)#clock rate 64000r0(config-if)#no shr0(config-if)#exr0(config)#r0(config)#router ripr0(config-router)#network 11.0.0.0r0(config-router)#network 12.0.0.0r0(config-router)#exr0(config)#exr0#r0#sh ip rouCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 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, * - candidate default U - per-user static route Gateway of last resort is not set C 11.0.0.0 is directly connected, Serial0 C 12.0.0.0 is directly connected, Serial1 R 192.168.1.0 120/1 via 11.1.1.1, 00:03:23, Serial0 R 193.168.1.0 120/1 via 12.1.1.1, 00:01:36, Serial1 r0#ping 192.168.1.1Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 16 页 - - - - - - - - - r0#ping 193.168.1.1Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 193.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r0#名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 16 页 - - - - - - - - - 四、 s1 配置switchenable(进入特权模式)switch#config terminal(进入全局配置模式)switch(config)# hostname S1(设置交换机的主机名)S1(config)# S1(config) #int vlan1S1(config-if)#ip a 192.168.1.2 255.255.255.0S1(config-if)#ip d 192.168.1.1 (设置默认网关)S1(config) #ex S1#sh ip int bri名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 16 页 - - - - - - - - - 五、 s2 配置switchenable(进入特权模式)switch#config terminal(进入全局配置模式)switch(config)# hostname S2(设置交换机的主机名)S2(config)# s2(config) #int vlan1s2(config-if) #ip a 193.168.1.2 255.255.255.0s2(config-if) #ip d 193.168.1.1 (设置默认网关)s2(config) #ex s2#sh ip int briInterface IP-Address OK? Method Status Protocol Vlan 1 193.168.1.2 YES unset up up FastEthernet0/1 unassigned YES unset up up FastEthernet0/2 unassigned YES unset up up FastEthernet0/3 unassigned YES unset up up FastEthernet0/4 unassigned YES unset down down FastEthernet0/5 unassigned YES unset down down FastEthernet0/6 unassigned YES unset down down FastEthernet0/7 unassigned YES unset down down FastEthernet0/8 unassigned YES unset down down FastEthernet0/9 unassigned YES unset down down FastEthernet0/10 unassigned YES unset down down FastEthernet0/11 unassigned YES unset down down FastEthernet0/12 unassigned YES unset down down s2#s2#s2# 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 16 页 - - - - - - - - - 六、 PC 配置PC1:192.168.1.11255.255.255.0192.168.1.1 PC2:192.168.1.12255.255.255.0192.168.1.1 PC3:193.168.1.11255.255.255.0193.168.1.1 PC4:193.168.1.12255.255.255.0193.168.1.1 配置如下:例:C:#C:#ip /ip 193.168.1.12 255.255.255.0 C:#ip /dg 193.168.1.1 C:#ip HELP Manipulates ip address for Workstation. IPCONFIG /ip /dg /ip Adds the ip address and subnet mask to the workstation /dg Adds the default gateway to the workstation Examples: ipconfig /ip 157.1.1.12 255.0.0.0 ipconfig /dg 157.1.1.1 Boson BOSS 5.0 IP Configuration Ethernet adapter Local Area Connection: IP Address. . . . . . . . . . . . : 193.168.1.12 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 193.168.1.1 You can also use winipcfg to configure the IP Address C:# 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 16 页 - - - - - - - - - 第二部分静态路由配置命令格式:r1(config)#ip route 12.0.0.0 255.0.0.0 11.1.1.1 要求1、R0:2 个 Serial0(2501)以上;2、R1:1 个 Serial0、1 个 Ethernet0(805) ;3、R2:1 个 Serial0、1 个 Ethernet0(805) ;4、S1、S2:2950 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 16 页 - - - - - - - - - 一、 R1 配置Router Routeren Router#con t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r1 r1(config)#int e0 r1(config-if)#ip add 192.168.1.1 255.255.255.0 r1(config-if)#no sh %LINK-3-UPDOWN: Interface Ethernet0, changed state to up r1(config-if)#exit r1(config)#int s0 r1(config-if)#ip add 11.1.1.1 255.0.0.0 r1(config-if)#clock rate 64000 %LINK-3-UPDOWN: Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up r1(config-if)#no sh r1(config-if)#ex r1(config)#r1(config)#ip route 11.0.0.0 255.0.0.0 11.1.1.1 (表示从该路由器发往11.0.0.0 255.0.0.0 网段的数据包其下一跳点的地址是11.1.1.1 )r1(config)#ip route 12.0.0.0 255.0.0.0 11.1.1.1 r1(config)#ip route 193.168.1.0 255.255.255.0 11.1.1.1 r1(config)#ex r1#ping 11.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.1.1.2, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#ping 12.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#ping 193.168.1.1/ 未配置 R0 时Type escape sequence to abort. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 16 页 - - - - - - - - - Sending 5, 100-byte ICMP Echos to 193.168.1.1, timeout is 2 seconds: . Success rate is 0 percent (0/5), round-trip min/avg/max = 1/2/4 ms r1#r1#r1#ping 193.168.1.1/配置 R0 后Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 193.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r1#名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 16 页 - - - - - - - - - 二、 R2 配置Router Routeren Router#con t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r2 r2(config)#int e0 r2(config-if)#ip add 193.168.1.1 255.255.255.0 r2(config-if)#no sh %LINK-3-UPDOWN: Interface Ethernet0, changed state to up r2(config-if)#ex r2(config)#int s0 r2(config-if)#ip add 12.1.1.1 255.0.0.0 r2(config-if)#clock rate 64000 %LINK-3-UPDOWN: Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up r2(config-if)#no sh r2(config-if)#ex r2(config)#r2(config)#ip route 12.0.0.0 255.0.0.0 12.1.1.1r2(config)#ip route 11.0.0.0 255.0.0.0 12.1.1.1r2(config)#ip route 192.168.1.0 255.255.255.0 12.1.1.1r2(config)#ex r2#ping 11.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.1.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r2#ping 12.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r2#ping 192.168.1.1/ 未配置 R0 时Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: . Success rate is 0 percent (0/5), round-trip min/avg/max = 1/2/4 ms r2#r2#名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 16 页 - - - - - - - - - r2#ping 192.168.1.1/配置 R0 后Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r2#名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 16 页 - - - - - - - - - 三、 R0 配置Router Routeren Router#con t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r0 r0(config)#int s0 r0(config-if)#ip add 11.1.1.2 255.0.0.0 r0(config-if)#clock rate 64000 r0(config-if)#ex r0(config)#int s1 r0(config-if)#ip add 12.1.1.2 255.0.0.0 r0(config-if)#clock rate 64000 r0(config-if)#ex r0(config)#r0(config)#ip route 11.0.0.0 255.0.0.0 11.1.1.2 r0(config)#ip route 12.0.0.0 255.0.0.0 12.1.1.2 r0(config)#ip route 192.168.1.0 255.255.255.0 11.1.1.2 r0(config)#ip route 193.168.1.0 255.255.255.0 12.1.1.2 r0(config)#ex r0# r0#ping 11.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.1.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r0#ping 12.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r0#ping 192.168.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r0#ping 193.168.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 193.168.1.1, timeout is 2 seconds: 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 15 页,共 16 页 - - - - - - - - - ! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms r0#r0#四、其它设备配置s1、s2、 PC 的配置同动态路由中的配置名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 16 页,共 16 页 - - - - - - - - -