静态路由 (2)
拓扑图
使用静态路由来确保不同网段的通信
为路由器和电脑设置IP地址
router 1 的设置
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#ip addr 192.168.1.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config)#int s0/3/0
Router(config-if)#ip addr 192.168.20.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#int s0/3/1
Router(config-if)#clock rate 64000
Router(config-if)#ip addr 192.168.10.1 255.255.255.0
Router(config-if)#no shu
router 2 的设置
Router>en
Router#conf t
Router(config)#
Router(config)#int f0/0
Router(config-if)#ip addr 192.168.2.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#ip addr 192.168.2.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/0
Router(config-if)#ip addr 192.168.20.2 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shu
Router(config-if)#ip addr 192.168.20.2 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/1
Router(config-if)#ip addr 192.168.30.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#ip addr 192.168.30.1 255.255.255.0
Router(config-if)#no shu
router 3 的设置
Router>
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#ip addr 192.168.3.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/1
Router(config-if)#ip addr 192.168.10.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/0
Router(config-if)#clock rate 64000
Router(config-if)#ip addr 192.168.30.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config)#
Router>en
Router#conf t
Router(config)#int f0/0
Router(config-if)#ip addr 192.168.3.1 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/1
Router(config-if)#ip addr 192.168.10.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config-if)#int s0/3/0
Router(config-if)#clock rate 64000
Router(config-if)#ip addr 192.168.30.2 255.255.255.0
Router(config-if)#no shu
Router(config-if)#
Router(config)#
为路由器配置静态路由
router 1 的配置
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.20.2
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.10.2
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.10.2
router 2 的配置
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.20.1
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.30.2
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.30.2
router 3 的配置
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.10.1
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.30.1
Router(config)#ip route 192.168.2.0 255.255.255.0 192.168.30.1
查看路由表
router 1 的路由表·
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
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
S 192.168.2.0/24 [1/0] via 192.168.20.2
S 192.168.3.0/24 [1/0] via 192.168.10.2
C 192.168.10.0/24 is directly connected, Serial0/3/1
C 192.168.20.0/24 is directly connected, Serial0/3/0
Router#
S 192.168.2.0/24 [1/0] via 192.168.20.2
S 192.168.3.0/24 [1/0] via 192.168.10.2
C 192.168.10.0/24 is directly connected, Serial0/3/1
C 192.168.20.0/24 is directly connected, Serial0/3/0
Router#
router 2 的路由表
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
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.20.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
S 192.168.3.0/24 [1/0] via 192.168.30.2
C 192.168.20.0/24 is directly connected, Serial0/3/0
C 192.168.30.0/24 is directly connected, Serial0/3/1
Router#
C 192.168.2.0/24 is directly connected, FastEthernet0/0
S 192.168.3.0/24 [1/0] via 192.168.30.2
C 192.168.20.0/24 is directly connected, Serial0/3/0
C 192.168.30.0/24 is directly connected, Serial0/3/1
Router#
router 3 的路由表
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
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.10.1
S 192.168.2.0/24 [1/0] via 192.168.30.1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.10.0/24 is directly connected, Serial0/3/1
C 192.168.30.0/24 is directly connected, Serial0/3/0
Router#
S 192.168.2.0/24 [1/0] via 192.168.30.1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.10.0/24 is directly connected, Serial0/3/1
C 192.168.30.0/24 is directly connected, Serial0/3/0
Router#
用ping 来检查网络的连通性
pc 1 ping pc 2
pc 1 ping pc 3
实验完成