路由器简单配置实例

 

路由器简单配置实例ide

 

以下图所示,主机0和主机1要经过路由器0和路由器1实现互相通讯,那么咱们要进行什么样的设置呢? 测试

实验前:spa

首先,咱们须要配置路由器0(设定路由器0/0接口的IP地址为192.168.1.1,接口0/1IP地址为192.168.2.1,子网掩码均为255.255.255.0),配置代码以下: 3d

第一步:配置路由器接口0/0IP地址,子网掩码。 orm

Router>enable /*从用户模式进入特权模式*/ blog

Router#config terminal /*从特权模式进入全局模式*/ 接口

Enter configuration commands, one per line.  End with CNTL/Z. ip

Router(config)#interface fastethernet 0/0  /*从全局模式进入接口模式,并指定对接口0/0进行配置*/ ci

Router(config-if)#ip address 192.168.1.1 255.255.255.0 /*在指定接口的接口模式下,对接口0/0设置IP地址,子网掩码 */ 路由

Router(config-if)#no shutdown /*开启路由器的指定接口*/

第二步,配置路由器接口0/1IP地址,子网掩码。

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 /*开启路由器的指定接口*/  

第三步,配置主机0IP地址,子网掩码,网关(192.168.1.2255.255.255.0192.168.1.1)。

再次,咱们须要配置路由器1(设定路由器0/0接口的IP地址为192.168.3.1,接口0/1IP地址为192.168.2.2,子网掩码均为255.255.255.0),配置代码以下:

第一步:配置路由器接口0/0IP地址,子网掩码。

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/1IP地址,子网掩码。

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 /*开启路由器的指定接口*/

第三步,配置主机1IP地址,子网掩码,网关(192.168.3.2255.255.255.0192.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下主机0TCP/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通了,主机0TCP/IP安装正确*/

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 10ms, Average = 5ms

PC>ping 192.168.1.2  /*ping下主机0IP,子网掩码是否设置正确*/

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通了,主机0IP,子网掩码设置正确*/

Approximate round trip times in milli-seconds:

    Minimum = 0ms, Maximum = 10ms, Average = 7ms

PC>ping 192.168.1.1  /*ping下路由器接口0/0IP,子网掩码是否设置正确*/

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/1IP,子网掩码是否设置正确*/

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/1IP,子网掩码是否设置正确*/

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/0IP,子网掩码是否设置正确*/

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下主机1IP,子网掩码是否设置正确*/  

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 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

C192.168.3.0/24 is directly connected, FastEthernet0/0

相关文章
相关标签/搜索