CCNA静态路由基本实验
需求
背景
这里我们需要通过对路由器里路由表的操作,来加深自己对静态路由的理解。这里我们给出了这么一个需求,有两台电脑,一台叫panjiahong,另外一台叫zhangyang。他们之间通过路由xuzhongwei相连。路由xuzhongwei通过其串口和路由zhengquan相连。另外有一台服务器叫liugongpeng,它和路由器zhengquan相连。
要求
这里我们有下面几个要求
1.电脑panjiahong和zhangyang能够通过路由xuzhongwei实行相互通信
2.电脑panjiahong和zhangyang能够通过路由xuzhongwei和路由zhengquan实行相互通信
3.电脑panjiahong和zhangyang能够通过路由xuzhongwei和路由zhengquan和服务器liugongpeng实现相互通信
需求图如下
操作
步骤
1.在packettracer中完成配线等layout,如下图所示
图2
这里需要注意的是PC和路由,以及server和路由需要用交叉线相连。而路由和路由的串口serial口需要用到DCE相连
2.配置PC(panjiahong,zhangyang)的静态ip地址和网关以及掩码.如下图
图3(配置panjiahong的网关)
图4(配置zhangyang的静态ip和子网掩码)
注意PC的网关必须和其连接的路由器的接口的ip一致,否则无法进行路由
3.配置路由xuzhongwei的f0/0和f1/0的ip地址.命令如下
Router(config)#host xuzhongwei
xuzhongwei(config)#
xuzhongwei(config)#int f0/0
xuzhongwei(config-if)#ip address 192.168.10.254 255.255.255.0
xuzhongwei(config-if)#no sh
xuzhongwei(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
xuzhongwei(config-if)#int f1/0
xuzhongwei(config-if)#ip address 192.168.20.254 255.255.255.0
xuzhongwei(config-if)#no sh
xuzhongwei(config-if)#
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
这个时候我们已经能够在PCzhangyang上ping通panjiahong了,如下图
图5(zhangyangping通panjiahong)
4.对路由xuzhongwei的serial2/0进行ip配置
xuzhongwei(config-if)#int s2/0
xuzhongwei(config-if)#ip address 10.1.1.1 255.0.0.0
xuzhongwei(config-if)#no sh
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
5.对路由zhengquan的serial2/0和f0/0进行ip配置
Router(config)#hostname zhengquan
zhengquan(config)#int s2/0
zhengquan(config-if)#ip address 10.1.1.2 255.0.0.0
zhengquan(config-if)#no sh
zhengquan(config-if)#
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
zhengquan(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
zhengquan(config-if)#
zhengquan(config-if)#int f0/0
zhengquan(config-if)#ip address 172.16.10.0 255.255.0.0
zhengquan(config-if)#no sh
zhengquan(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
6.配置server liugongpeng的f0/0的静态ip地址和网关以及掩码.和PC的配置相似,在此省略图片
7.检查连线
到目前为止路由xuzhongwei和路由zhengquan之间可以相互通信,路由zhengquan和server liugongpeng之间也可以相互通信了
xuzhongwei->zhengquan
xuzhongwei#ping 10.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/5/14 ms
zhengquan->xuzhongwei
zhengquan#ping 10.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/3 ms
zhengquan->liugongpeng
zhengquan#ping 172.16.30.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.30.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
liugongpeng->zhengquan
Packet Tracer SERVER Command Line 1.0
C:\>ping 172.16.10.0
Pinging 172.16.10.0 with 32 bytes of data:
Reply from 172.16.10.0: bytes=32 time<1ms TTL=255
Reply from 172.16.10.0: bytes=32 time<1ms TTL=255
Reply from 172.16.10.0: bytes=32 time<1ms TTL=255
Reply from 172.16.10.0: bytes=32 time<1ms TTL=255
Ping statistics for 172.16.10.0:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
但是目前为止,想要实现panjiahong,zhangyang到zhengquan的通信是不可能的.比如说panjiahong现在想ping通zhengquan的s2/0口的10.1.1.2
C:\>ping 10.1.1.2
Pinging 10.1.1.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 10.1.1.2:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
原因在于panjiahong通过路由xuzhongwei能够找到路由zhengquan上的s2/0口但是路由zhengquan不知道panjiahong在哪儿,所以ping出去的信息能够抵达,但是因为不知道回来的路所以无法得到目标的response
因此在这里为了帮助panjiahong对zhengquan的ping信息找到回头路需要在zhengquan上添加路由表,告诉zhengquan只要找到路由xuzhongwei就能找到panjiahongle
在zhengquan上添加路由表,指向xuzhongwei的s2/0的接口ip地址,让所有192.168.0.0/16的ip都指向xuzhongwei
zhengquan>enable
zhengquan#conf t
Enter configuration commands, one per line. End with CNTL/Z.
zhengquan(config)#ip route 192.168.0.0 255.255.0.0 10.1.1.1
在此在panjiahong上尝试,发现可以ping通zhengquan的s2/0接口上的ip了
```
Pinging 10.1.1.2 with 32 bytes of data:
Reply from 10.1.1.2: bytes=32 time=1ms TTL=254
Reply from 10.1.1.2: bytes=32 time=1ms TTL=254
Reply from 10.1.1.2: bytes=32 time=1ms TTL=254
Reply from 10.1.1.2: bytes=32 time=1ms TTL=254
Ping statistics for 10.1.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 1ms, Average = 1ms
```
我们又进了一步,那么我们现在能不能在panjiahong上ping通zhengquan的f0/0的ip呢
C:\>ping 172.16.10.0
Pinging 172.16.10.0 with 32 bytes of data:
Reply from 192.168.10.254: Destination host unreachable.
Reply from 192.168.10.254: Destination host unreachable.
Reply from 192.168.10.254: Destination host unreachable.
Reply from 192.168.10.254: Destination host unreachable.
Ping statistics for 172.16.10.0:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
这里我们发现也是ping不同的,但是错误提示不再是timeout了,而是不可到达。我们仔细分析一下也能想到,当ping信息到达路由器xuzhongwei以后,xuzhongwei也不知道172.16.10.0在哪里,虽然是在它相邻的路由器zhengquan上,但是和zhengquan想接的接口是zhengquan的s2/0(10.1.1.2).
要解决这个问题我们需要告诉路由xuzhongwei,去172.16.10.0的路怎么走。因为要想去172.16.10.0实际上就是去路由zhengquan,所以我们需要如下对路由xuzhongwei进行指定静态路由设置。
xuzhongwei>enable
xuzhongwei#
xuzhongwei#conf t
Enter configuration commands, one per line. End with CNTL/Z.
xuzhongwei(config)#ip route 172.16.0.0 255.255.0.0 10.1.1.2
然后我们在panjiahong上对172.16.10.0进行ping操作,发现已经可以ping成功了。
C:\>ping 172.16.10.0
Pinging 172.16.10.0 with 32 bytes of data:
Reply from 172.16.10.0: bytes=32 time=5ms TTL=254
Reply from 172.16.10.0: bytes=32 time=3ms TTL=254
Reply from 172.16.10.0: bytes=32 time=1ms TTL=254
Reply from 172.16.10.0: bytes=32 time=15ms TTL=254
Ping statistics for 172.16.10.0:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 15ms, Average = 6ms
也许你会有疑问,我们只是告诉了去的路还没有指定回来的路啊,这是因为在上一步的配置中,我们已经在路由器zhengquan上指明了回来的录了。在路由器zhengquan上查看路由表
zhengquan>enable
zhengquan#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 10.0.0.0/8 is directly connected, Serial2/0
C 172.16.0.0/16 is directly connected, FastEthernet0/0
S 192.168.0.0/16 [1/0] via 10.1.1.1
S 192.168.0.0/16 [1/0] via 10.1.1.1就是回来的路啊,要去192.168.0.0/16的ip就去找旁边的xuzhongwei啊。
8.最后攻关。如果理解了上面的内容那么想要实现PC到server的通讯的思路也会变得清晰起来。这里不解释了,提刀上马。
1.先清空xuzhongwei和zhengquan的所有路由表
2.配置
2.1在xuzhongwei上指明去的路
xuzhongwei(config)#ip route 172.16.0.0 255.255.0.0 10.1.1.2
2.2在zhengquan上指明回去的路
zhengquan(config)#ip route 192.168.0.0 255.255.0.0 10.1.1.1
如图8所示,这个在zhangyang上ping通了liugongpeng的server。实验成功!!!!!
祝大家生活愉快