多个路由器配置静态路由|多个路由器配置静态路由 简单
在路由器的配置中管理距离什么意思
管理距离
缩写:AD 管理距离是指一种路由协议的路由可信度。每一种路由协议按可靠性从高到低,依次分配一个信任等级,这个信任等级就叫管理距离。
对于两种不同的路由协议到一个目的地的路由信息,路由器首先根据管理距离决定相信哪一个协议。 AD值越低,则它的优先级越高。 一个管理距离是一个从0——255的整数值,0是最可信赖的,而255则意味着不会有业务量通过这个路由。 直连的AD=0, static 静态的AD=1,EIGRP的AD=90,IGRP的AD=100,OSPF的AD=110,RIP的AD=120.
四个路由器,每个路由器就要配三条静态路由ip,以此类推
N=路由器
n-1=每个路由器就要配n-1条静态路由ip
静态IP很好配
1 在各个接口上配置好ip ,然后到配置模式 ip route 网络地址 目的地址
例如在route10的机器上配置如下:
(这个叫网络地址)(这个叫目的地址,也叫下一跳)
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
Router(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.1
Router(config)#ip route 192.168.5.0 255.255.255.0 192.168.4.2
Router(config)#end
Router#write
整个拓扑配置如下
Route10上操作的
Router10>enable
Router10#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router10(config)#interface fastEthernet 0/0
Router10(config-if)#ip address 192.168.1.254 255.255.255.0
Router10(config-if)#no shutdown
Router10(config)#end
Router10#configure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router10(config)#interface fastEthernet 0/1
Router10(config-if)#ip address 192.168.2.1 255.255.255.0
Router10(config-if)#no shutdown
Router10(config)#end
Router10(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
Router10(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.1
Router10(config)#ip route 192.168.5.0 255.255.255.0 192.168.4.2
Router10(config)#end
Router10#write
Route11上操作的
Router11>enable
Router11#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router11(config)#interface fastEthernet 0/0
Router11(config-if)#ip address 192.168.2.2 255.255.255.0
Router11(config-if)#no shutdown
Router11(config-if)#exit
Router11(config)#interface fastEthernet 0/1
Router11(config-if)#ip address 192.168.3.2 255.255.255.0
Router11(config-if)#no shutdown
Router11(config-if)#end
Router11#write
Building configuration...
[OK]
Router11(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
Router11(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.1
Router11(config)#ip route 192.168.5.0 255.255.255.0 192.168.4.2
Router11(config)#end
Router11#write
Route12上操作的
Router12>enable
Router12#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router12(config)#interface fastEthernet 0/0
Router12(config-if)#ip address 192.168.3.1 255.255.255.0
Router12(config-if)#no shutdown
Router12(config-if)#exit
【多个路由器配置静态路由|多个路由器配置静态路由 简单】Router12(config)#interface fastEthernet 0/1
Router12(config-if)#ip address 192.168.4.1 255.255.255.0
Router12(config-if)#no shutdown
Router12(config-if)#end
Router12#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router12(config)#
Router12(config)#ip route 192.168.5.0 255.255.255.0 192.168.4.2
Router12(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.2
Router12(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
Router12(config)#end
Router12#write
Route13上操作的
Router>enable
Router#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 192.168.4.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 192.168.5.254 255.255.255.0
Router(config-if)#no shutdown
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.4.1
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.2
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.2.1
Router(config)#end出错了
Router#write
Building configuration...
[OK]
Router#configure t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#no ip route 192.168.2.0 255.255.255.0 192.168.2.1 删除路由所以才会有这条
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
Router(config)#end
Router#write
文章图片
Top
NSD NETWORK DAY05
- 配置静态路由
1 配置静态路由 1.1 问题
路由器可以将不同网段之间的网络连接到一起,当路由器接收到数据包后要查看数据包中的目标IP,再检查自己的路由表,如果路由表中有和目标IP相匹配的路由条目,路由器才能将数据包按照该路由条目所指定的端口转发出去,实现不同网络之间的通信,那么路由器中的路由表是如何实现的呢?配置了路由器接口IP并为UP状态路由表中自动生成直连路由,对于非直连的路由,需通过静态路由管理员手工添加或通过配置动态路自动学习。
- 配置静态路由
- 配置浮动静态路由
- 配置缺省路由
网络环境及IP地址规划,如图-1所示。
文章图片
图-1
本例中的配置练习采用思科模拟器 —— Cisco Packet Tracer 6.0,Route采用2621路由器实现。
1.3 步骤
实现此案例需要按照如下步骤进行。
步骤一:配置静态路由
1)R1上配置接口IP
- R1(config)#interface fastEthernet 0/0
- R1(config-if)#ip address 192.168.1.254 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R1(config)#interface fastEthernet 0/1
- R1(config-if)#ip address 192.168.2.1 255.255.255.0
- R1(config-if)#no shutdown
- R2(config)#interface fastEthernet 0/1
- R2(config-if)#ip address 192.168.2.2 255.255.255.0
- R2(config-if)#no shutdown
- R2config-if)#exit
- R2(config)#interface fastEthernet 0/0
- R2(config-if)#ip address 192.168.3.254 255.255.255.0
- R2(config-if)#no shutdown
- R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
- R1#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 not set
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- S 192.168.3.0/24 [1/0] via 192.168.2.2 //S表示静态路由
- R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
- R2#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 not set
- S 192.168.1.0/24 [1/0] via 192.168.2.1 //S表示静态路由
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- C 192.168.3.0/24 is directly connected, FastEthernet0/0
8)配置PC2的IP地址为192.168.3.1,网关为192.168.3.254
9)测试网络连通性,PC1 ping 192.168.3.1
- PC>ping 192.168.3.1
- Pinging 192.168.3.1 with 32 bytes of data:
- Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=10ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
- Ping statistics for 192.168.3.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 1ms, Maximum = 11ms, Average = 8ms
1)在以上静态路由实验的基础上,先分别进入R1与R2的特权模式输入write命令保存配置信息,然后分别进入R1与R2的物理配置界面,点击开关按钮关闭路由器,添加NM-1FE-TX模块并再次点击开关按钮,如下图-2所示。
图-2
文章图片
2)添加模块后将R1的F1/0接口连接到R2的F1/0接口修改拓扑如下图-3所示:
文章图片
图-3
3)配置R1的F1/0接口IP
- R1(config)#interface fastEthernet 1/0
- R1(config-if)#ip address 192.168.4.1 255.255.255.0
- R1(config-if)#no shutdown
- R2(config)#interface fastEthernet 1/0
- R2(config-if)#ip address 192.168.4.2 255.255.255.0
- R2(config-if)#no shutdown
- R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.4.2 50 //管理距离50
- R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.4.1 50 //管理距离50
- R1#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 not set
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- S 192.168.3.0/24 [1/0] via 192.168.2.2
- C 192.168.4.0/24 is directly connected, FastEthernet1/0
- R1#show ip rou
- R1#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 not set
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- S 192.168.3.0/24 [1/0] via 192.168.2.2 //只有下一跳为192.168.2.2的静态路由
- C 192.168.4.0/24 is directly connected, FastEthernet1/0
- R1(config)#interface fastEthernet 0/1
- R1(config-if)#shutdown
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- S 192.168.3.0/24 [50/0] via 192.168.4.2//下一跳接口为192.168.4.2的路由生效
- C 192.168.4.0/24 is directly connected, FastEthernet1/0
- PC>ping 192.168.3.1
- Pinging 192.168.3.1 with 32 bytes of data:
- Reply from 192.168.3.1: bytes=32 time=0ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=10ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=11ms TTL=126
- Reply from 192.168.3.1: bytes=32 time=1ms TTL=126
- Ping statistics for 192.168.3.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 11ms, Average = 5ms
1)网络环境及IP地址规划,如图-4所示
图-4
文章图片
2)R1上配置接口IP
- Router(config)#interface fastEthernet 0/0
- R1(config-if)#ip address 192.168.1.254 255.255.255.0
- R1(config-if)#no shutdown
- R1(config-if)#exit
- R1(config)#interface fastEthernet 0/1
- R1(config-if)#ip address 192.168.2.1 255.255.255.0
- R1(config-if)#no shutdown
- R2(config)#interface f0/1
- R2(config-if)#ip address 192.168.2.2 255.255.255.0
- R2(config-if)#no shutdown
- R2(config-if)#exit
- R2(config)#interface fastEthernet 0/0
- R2(config-if)#ip address 192.168.3.1 255.255.255.0
- R2(config-if)#no shutdown
- R3(config)#interface fastEthernet 0/1
- R3(config-if)#ip address 192.168.3.2 255.255.255.0
- R3(config-if)#no shutdown
- R3(config-if)#exit
- R3(config)#interface fastEthernet 0/0
- R3(config-if)#ip address 192.168.4.254 255.255.255.0
- R3(config-if)#no shutdown
- R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
- R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
- R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
- R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
- R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
- R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
- R1#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 not set
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- S 192.168.3.0/24 [1/0] via 192.168.2.2 //静态路由
- S 192.168.4.0/24 [1/0] via 192.168.2.2 //静态路由
- R2#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 not set
- S 192.168.1.0/24 [1/0] via 192.168.2.1 //静态路由
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- C 192.168.3.0/24 is directly connected, FastEthernet0/0
- S 192.168.4.0/24 [1/0] via 192.168.3.2 //静态路由
- R3#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 not set
- S 192.168.1.0/24 [1/0] via 192.168.3.1 //静态路由
- S 192.168.2.0/24 [1/0] via 192.168.3.1 //静态路由
- C 192.168.3.0/24 is directly connected, FastEthernet0/1
- C 192.168.4.0/24 is directly connected, FastEthernet0/0
10)测试网络连通性,PC1 ping 192.168.2.2、192.168.3.1、192.168.3.2、192.168.4.1
- PC>ping 192.168.2.2 //ping 192.168.2.2
- Pinging 192.168.2.2 with 32 bytes of data:
- Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
- Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
- Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
- Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
- Ping statistics for 192.168.2.2:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 0ms, Average = 0ms
- PC>ping 192.168.3.1 //ping 192.168.3.1
- Pinging 192.168.3.1 with 32 bytes of data:
- Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
- Reply from 192.168.3.1: bytes=32 time=3ms TTL=254
- Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
- Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
- Ping statistics for 192.168.3.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 3ms, Average = 0ms
- PC>ping 192.168.3.2 //ping 192.168.3.2
- Pinging 192.168.3.2 with 32 bytes of data:
- Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
- Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
- Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
- Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
- Ping statistics for 192.168.3.2:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 12ms, Average = 6ms
- PC>ping 192.168.4.1 //ping 192.168.4.1
- Pinging 192.168.4.1 with 32 bytes of data:
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=10ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=22ms TTL=125
- Ping statistics for 192.168.4.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 22ms, Average = 8ms
- R1(config)#no ip route 192.168.3.0 255.255.255.0 192.168.2.2
- R1(config)#no ip route 192.168.4.0 255.255.255.0 192.168.2.2
- R3(config)#no ip route 192.168.1.0 255.255.255.0 192.168.3.1
- R3(config)#no ip route 192.168.2.0 255.255.255.0 192.168.3.1
- R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
- R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1
- R1#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.2.2 to network 0.0.0.0
- C 192.168.1.0/24 is directly connected, FastEthernet0/0
- C 192.168.2.0/24 is directly connected, FastEthernet0/1
- S* 0.0.0.0/0 [1/0] via 192.168.2.2 //默认路由
- R3#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.3.1 to network 0.0.0.0
- C 192.168.3.0/24 is directly connected, FastEthernet0/1
- C 192.168.4.0/24 is directly connected, FastEthernet0/0
- S* 0.0.0.0/0 [1/0] via 192.168.3.1 //默认路由
- PC>ping 192.168.4.1
- Pinging 192.168.4.1 with 32 bytes of data:
- Reply from 192.168.4.1: bytes=32 time=1ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
- Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
- Ping statistics for 192.168.4.1:
- Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
- Approximate round trip times in milli-seconds:
- Minimum = 0ms, Maximum = 14ms, Average = 7ms
如若还不明白就看下面这个
转载于:https://www.cnblogs.com/fyy-hhzzj/p/8258836.html
推荐阅读
- vue-cli|vue-cli 3.x vue.config.js 配置
- 从战略性的角度可以配置股票
- Android|Android install 多个设备时指定设备
- 缓存有关的配置和属性
- Spring|Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件
- Vagrant|Vagrant (三) - 网络配置
- java|java b2b2c shop 多用户商城系统源码- config 修改配置
- CentOS7 阿里云镜像配置方法
- K8S|K8S 生态周报| Istio 即将发布重大安全更新,多个版本受影响
- Python|Win10下 Python开发环境搭建(PyCharm + Anaconda) && 环境变量配置 && 常用工具安装配置