这是今天在技术员协助下完成的一个联网实验,两台PC主机(0和1)连接,中间经过两台路由器(也分别命名为0和1),这样的4个设备组成的简单网络,主机0和主机1要通过路由器0和路由器1实现互相通信,那么我们要进行什么样的设置才能达到目的呢? 首先,我们需要配置路由器0(设定路由器0/0接口的IP地址为192.168.1.1,接口0/1的IP地址为192.168.2.1,子网掩码均为255.255.255.0),配置代码如下: 第一步:配置路由器接口0/0的IP地址,子网掩码。 Router>enable /*从用户模式进入特权模式*/ Router#config terminal /*从特权模式进入全局模式*/ Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastethernet 0/0 /*从全局模式进入接口模式,并指定对接口0/0进行配置*/ Router(config-if)#ip address 192.168.1.1 255.255.255.0 /*在指定接口的接口模式下,对接口0/0设置IP地址,子网掩码 */ Router(config-if)#no shutdown /*开启路由器的指定接口*/
Router#config terminal /*从特权模式进入全局模式*/ Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastethernet 0/1 /*从全局模式进入接口模式,并指定对接口0/1进行配置*/ Router(config-if)#ip address 192.168.2.1 255.255.255.0 /*在指定接口的接口模式下,对接口0/1设置IP地址,子网掩码 */ Router(config-if)#no shutdown /*开启路由器的指定接口*/ 第三步,配置主机0的IP地址,子网掩码,网关(192.168.1.2,255.255.255.0,192.168.1.1)。 再次,我们需要配置路由器1(设定路由器0/0接口的IP地址为192.168.3.1,接口0/1的IP地址为192.168.2.2,子网掩码均为255.255.255.0),配置代码如下: 第一步:配置路由器接口0/0的IP地址,子网掩码。 Router>enable /*从用户模式进入特权模式*/ Router#config terminal /*从特权模式进入全局模式*/ Enter configuration commands, one per line. End with CNTL/Z. Router(config)#interface fastethernet 0/0 /*从全局模式进入接口模式,并指定对接口0/0进行配置*/ Router(config-if)#ip address 192.168.3.1 255.255.255.0 /*在指定接口的接口模式下,对接口0/0设置IP地址,子网掩码 */ Router(config-if)#no shutdown /*开启路由器的指定接口*/ 第二步,配置路由器接口0/1的IP地址,子网掩码。 Router(config-if)#exit /*从上一指定接口模式下退出,进入下一指定接口的接口模式 */ Router(config)#interface fastethernet 0/1 /*从全局模式进入接口模式,并指定对接口0/1进行配置*/ Router(config-if)#ip address 192.168.2.2 255.255.255.0 /*在指定接口的接口模式下,对接口0/1设置IP地址,子网掩码 */ Router(config-if)#no shutdown /*开启路由器的指定接口*/ 第三步,配置主机1的IP地址,子网掩码,网关(192.168.3.2,255.255.255.0,192.168.3.1)。 然后,我们需要设置路由器0和路由器1的静态路由和下一跳地址。 第一步,设置路由器0的静态路由和下一跳地址。 Router(config)#interface fastethernet 0/0 /*从全局模式进入接口模式,并指定对接口0/0进行配置*/ Router(config-if)#ip route 192.168.3.0 255.255.255.0 192.168.2.2 /*设定路由器0的目标地址和子网掩码以及其下一跳地址*/ 第二步,设置路由器1的静态路由和下一跳地址。 Router(config)#interface fastethernet 0/0 /*从全局模式进入接口模式,并指定对接口0/0进行配置*/ Router(config-if)#ip route 192.168.1.0 255.255.255.0 192.168.2.1 /*设定路由器0的目标地址和子网掩码以及其下一跳地址*/ 最后,进行测试,主机0和主机1是否能正常通信呢。 第一步,先从主机0开始,代码如下: Packet Tracer PC Command Line 1.0 PC>ping 127.0.0.1 /*ping下主机0的TCP/IP是否安装正确*/ Pinging 127.0.0.1 with 32 bytes of data: Reply from 127.0.0.1: bytes=32 time=10ms TTL=128 Reply from 127.0.0.1: bytes=32 time=10ms TTL=128 Reply from 127.0.0.1: bytes=32 time=2ms TTL=128 Reply from 127.0.0.1: bytes=32 time=0ms TTL=128 Ping statistics for 127.0.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,主机0的TCP/IP安装正确*/ Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 10ms, Average = 5ms PC>ping 192.168.1.2 /*ping下主机0的IP,子网掩码是否设置正确*/ Pinging 192.168.1.2 with 32 bytes of data: Reply from 192.168.1.2: bytes=32 time=10ms TTL=128 Reply from 192.168.1.2: bytes=32 time=10ms TTL=128 Reply from 192.168.1.2: bytes=32 time=10ms TTL=128 Reply from 192.168.1.2: bytes=32 time=0ms TTL=128 Ping statistics for 192.168.1.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,主机0的IP,子网掩码设置正确*/ Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 10ms, Average = 7ms PC>ping 192.168.1.1 /*ping下路由器接口0/0的IP,子网掩码是否设置正确*/ Pinging 192.168.1.1 with 32 bytes of data: Reply from 192.168.1.1: bytes=32 time=40ms TTL=255 Reply from 192.168.1.1: bytes=32 time=20ms TTL=255 Reply from 192.168.1.1: bytes=32 time=20ms TTL=255 Reply from 192.168.1.1: bytes=32 time=20ms TTL=255 Ping statistics for 192.168.1.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,路由器的接口0/0设置正确*/ Approximate round trip times in milli-seconds: Minimum = 20ms, Maximum = 40ms, Average = 25ms PC>ping 192.168.2.1 /*ping下路由器0接口0/1的IP,子网掩码是否设置正确*/ Pinging 192.168.2.1 with 32 bytes of data: Reply from 192.168.2.1: bytes=32 time=20ms TTL=255 Reply from 192.168.2.1: bytes=32 time=20ms TTL=255 Reply from 192.168.2.1: bytes=32 time=20ms TTL=255 Reply from 192.168.2.1: bytes=32 time=20ms TTL=255 Ping statistics for 192.168.2.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,路由器0的接口0/1设置正确*/ Approximate round trip times in milli-seconds: Minimum = 20ms, Maximum = 20ms, Average = 20ms PC>ping 192.168.2.2 /*ping下路由器1接口0/1的IP,子网掩码是否设置正确*/ Pinging 192.168.2.2 with 32 bytes of data: Reply from 192.168.2.2: bytes=32 time=40ms TTL=254 Reply from 192.168.2.2: bytes=32 time=40ms TTL=254 Reply from 192.168.2.2: bytes=32 time=40ms TTL=254 Reply from 192.168.2.2: bytes=32 time=40ms TTL=254 Ping statistics for 192.168.2.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,路由器1的接口0/1设置正确*/ Approximate round trip times in milli-seconds: Minimum = 40ms, Maximum = 40ms, Average = 40ms PC>ping 192.168.3.1 /*ping下路由器1接口0/0的IP,子网掩码是否设置正确*/ Pinging 192.168.3.1 with 32 bytes of data: Reply from 192.168.3.1: bytes=32 time=40ms TTL=254 Reply from 192.168.3.1: bytes=32 time=30ms TTL=254 Reply from 192.168.3.1: bytes=32 time=40ms TTL=254 Reply from 192.168.3.1: bytes=32 time=31ms TTL=254 Ping statistics for 192.168.3.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,路由器1的接口0/1设置正确*/ Approximate round trip times in milli-seconds: Minimum = 30ms, Maximum = 40ms, Average = 35ms PC>ping 192.168.3.2 /*ping下主机1的IP,子网掩码是否设置正确*/ Pinging 192.168.3.2 with 32 bytes of data: Reply from 192.168.3.2: bytes=32 time=60ms TTL=126 Reply from 192.168.3.2: bytes=32 time=60ms TTL=126 Reply from 192.168.3.2: bytes=32 time=60ms TTL=126 Reply from 192.168.3.2: bytes=32 time=60ms TTL=126 Ping statistics for 192.168.3.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), /*从此处可以看出丢包率是0,说明ping通了,主机设置正确*/ Approximate round trip times in milli-seconds: Minimum = 60ms, Maximum = 60ms, Average = 60ms 第二步,主机1到主机0。/*解释说明和主机0到主机1是一样的,下面就不在详细阐述了,请谅解!*/ 路由器0:通过“show ip route”命令来查看路由表。 Router>show http://www.luyouqiwang.com/14201/ 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 路由器1:通过“show ip route”命令来查看路由表。 Router> Router>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 |
不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流
GMT+8, 2025-9-4 06:09 , Processed in 0.097502 second(s), 16 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.