**
Cisco Packet Tracer 静态路由配置
**
一、拓扑图
二、配置PC、路由器
PC0:
PC1:
route0:
Router>en
Router#conf t
Router(config)#hostname route0
route0(config)#int f0/0
route0(config-if)#ip ad 192.168.10.1 255.255.255.0
route0(config-if)#no sh
route0(config)#int s2/0
route0(config-if)#ip ad 192.168.20.1 255.255.255.0
route0(config-if)#no sh
route0(config)#int s2/0
route0(config-if)#clock rate 64000
因为路由器是背对背连接的,所以把两个背对背连接的串口其中一个设置为DCE
route1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname route1
route1(config)#int s2/0
route1(config-if)#ip ad 192.168.20.2 255.255.255.0
route1(config-if)#no sh
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
route1(config-if)#int s3/0
route1(config-if)#ip ad 192.168.30.1 255.255.255.0
route1(config-if)#no sh
%LINK-5-CHANGED: Interface Serial3/0, changed state to down
route2:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname route2
route2(config)#int s3/0
route2(config-if)#ip ad 192.168.30.2 255.255.255.0
route2(config-if)#no sh
%LINK-5-CHANGED: Interface Serial3/0, changed state to up
route2(config-if)#int f0/0
route2(config-if)#ip ad 192.168.40.1 255.255.255.0
route2(config-if)#no sh
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
配置route0静态路由:
route0自己的网络192.168.10.0和192.168.20.0(直接相连),所以route0的路由表必须加入192.168.30.0和192.168.40.0的信息,注意下一跳接口(数据包经过的下一个接口),配置如下:
route0(config-if)#exit
route0(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2
说的通俗点就是要去192.168.30.0网络就要去找192.168.20.2接口发送数据包
route0(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.2
要去192.168.40.0网络就要去找192.168.20.2接口发送数据包
配置route1静态路由:
route1要学习到的网络应该是192.168.10.0和192.168.40.0,配置如下:
route1(config-if)#exit
route1(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1
要去192.168.10.0这个网段的网络就要去找192.168.20.1接口发送数据包
route1(config)#ip route 192.168.40.0 255.255.255.0 192.168.30.2
要去192.168.40.0这个网段的网络就要去找192.168.30.2接口发送数据包
配置route2静态路由:
route2要学习到的网络应该是192.168.10.10和192.168.20.0,配置如下:
route2(config)#ip route 192.168.10.0 255.255.255.0 192.168.30.1
要去192.168.10.0这个网段的网络就要去找192.168.30.1接口发送数据包
route2(config)#ip route 192.168.20.0 255.255.255.0 192.168.30.1
要去192.168.20.0这个网段的网络就要去找192.168.30.1接口发送数据包
测试连接:
PC0 ping PC1
可以ping通说明网络没问题。
路由信息:
route0#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.10.0/24 is directly connected, FastEthernet0/0
C 192.168.20.0/24 is directly connected, Serial2/0
S 192.168.30.0/24 [1/0] via 192.168.20.2
S 192.168.40.0/24 [1/0] via 192.168.20.2
上面输出中S代表静态路由,C代表直接相连,[1/0]分布为管理距离和度,via代表下一跳。