Skip to main content

 路由器设置 > 新闻资讯 >

【实验】通过路由器联通外网

2014-04-20 01:46 浏览:

  实验一

  实验名称:搭建一个连通外网的环境

  实验过程

  步骤1:配置基本环境

  首先,打开Cisco Packet Tacer,购买三台主机,一台交换机,一台路由器,并用合适的线缆连接起来。单击主机选择Desktop-ipconfiguration,为三台主机分别配192.168.1.1;192.168.1.2;192.168.1.3的IP。

  步骤2:配置交换机的IP与网关

  单击交换机进入CLI命令行模式输入enable进入特权模式,输入configure terminal 进入全局配置模式;在全局配置模式下 interface vlan 1- ip address 192.168.1.253 255.255.255.0 -no shutdown;

  Switch>enable

  Switch#configure terminal

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

  Switch(config)#interface vlan 1

  Switch(config-if)#ip address 192.168.1.253 255.255.255.0

  Switch(config-if)#no shutdown

  Switch(config-if)#

  %LINK-5-CHANGED: Interface Vlan1, changed state to up

  %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

  Switch(config-if)#

  这样就配置好了交换机IP。为了验证我们可以主机1 ping一下交换机IP。

  ping statistics for 192.168.1.253:

  Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),

  Approximate round trip times in milli-seconds:

  Minimum = 0ms, Maximum = 0ms, Average = 0ms

  发现时可以ping通的。下面输入exit回到全局配置模式。在命令行输入ip default-gateway 192.168.1.100就可以为交换机配置网关,这样可以方便不同网段主机对交换机的管理。

  步骤3:配置路由器接口IP

  单击路由器进入CLI命令行模式,通交换机一样,enable进入用户模式,configure terminal 进入全局配置模式。输入interface fastethernet 0/0进入接口,输入ip address 192.168.1.254 255.255.255.0然后no shutdown。

  Router>enable

  Router#configure terminal

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

  Router(config)#

  Router(config)#interface fastethernet 0/0

  Router(config-if)#ip address 192.168.1.254 255.255.255.0

  Router(config-if)#no shutdown

  Router(config-if)#

  %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

  %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

  Router(config-if)#

  这样就配置好了路由器的IP了,用一个主机ping一下

  PC>ping 192.168.1.254

  Pinging 192.168.1.254 with 32 bytes of data:

  Reply from 192.168.1.254: bytes=32 time=2ms TTL=255

  Reply from 192.168.1.254: bytes=32 time=0ms TTL=255

  Reply from 192.168.1.254: bytes=32 time=0ms TTL=255

  Reply from 192.168.1.254: bytes=32 time=0ms TTL=255

  Ping statistics for 192.168.1.254:

  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

  Approximate round trip times in milli-seconds:

  Minimum = 0ms, Maximum = 2ms, Average = 0ms

  PC>

  可以Ping通,至此,实验完成。

  实验结果:本次实验其实不难,主要的还是在于熟练,工作上以后,对于这样的操作,应该做到秒杀。