靜態路由配置(Static Routing)



1.按照試驗拓撲,配置好路由器的各個接口IP;
2.使用ping命令驗證路由器之間的連同性,以r1爲例:

r1#ping 10.3.3.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/67/116 ms
略......

再用r1 ping r2的loopback和r3的ip:

r1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
略......

r1無法ping通r2的loopback地址和r3的ip地址,需要添加靜態路由。
3.下面在3臺路由器上使用命令ip route添加相應的靜態路由:

r1(config)#ip route 192.168.1.0 255.255.255.0 10.3.3.2         //設置靜態路由到192.168.1.0/24,                                                                                                   下一跳地址爲10.3.3.2 r1(config)#ip route 172.16.3.0 255.255.255.0 10.3.3.2
r1(config)#ip route 172.16.1.0 255.255.255.0 10.3.3.2
r1(config)#ip route 172.16.2.0 255.255.255.224 10.3.3.2
r2(config)#ip route 10.1.1.0 255.255.255.0 10.3.3.1
r2(config)#ip route 10.2.2.0 255.255.255.224 10.3.3.1
r2(config)#ip route 172.16.1.0 255.255.255.0 172.16.3.1
r2(config)#ip route 172.16.2.0 255.255.255.224 172.16.3.1
r3(config)#ip route 192.168.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.3.3.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.1.1.0 255.255.255.0 172.16.3.2
r3(config)#ip route 10.2.2.0 255.255.255.224 172.16.3.2

然後再次驗證:

r1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/59/60 ms
其餘略......

可以ping通。
查看一下r1的路由表:

r1#show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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
     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks
S       172.16.1.0/24 [1/0] via 10.3.3.2
S       172.16.2.0/27 [1/0] via 10.3.3.2
S       172.16.3.0/24 [1/0] via 10.3.3.2
     10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C       10.3.3.0/24 is directly connected, Serial1/1
C       10.2.2.0/27 is directly connected, Loopback1
C       10.1.1.0/24 is directly connected, Loopback0
S    192.168.1.0/24 [1/0] via 10.3.3.2

S代表靜態路由。(其餘路由器略......)
總結:其實如果路由器屬於末梢節點的話,可以只用一條默認路由也可以實現上面的效果,例如r1:

r1(config)#ip route 0.0.0.0 0.0.0.0 10.3.3.2

這樣也可以ping通其餘的ip地址。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章