Static Route靜態路由

       靜態路由基礎設定  

192.168.0.1的這台電腦要與192.168.1.1這台電腦互通,在沒有路由的情況下是會在router就會迷路了。

        所以我們可以檢查一下路由的狀況:

Router-0#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

 

     10.0.0.0/29 is subnetted, 1 subnets

C       10.1.1.0 is directly connected, FastEthernet0/1  只認得和自己相連的網段

C    192.168.0.0/24 is directly connected, FastEthernet0/0

        建立一筆通往10.1.1.2的路由:

Router-0(config)#ip route 192.168.1.0 255.255.255.0 10.1.1.2

收到目的地是往192.168.1.0/255.255.255.0網段的封包時,請往10.1.1.2轉送

Router-0(config)#exit

Router-0#

%SYS-5-CONFIG_I: Configured from console by console

 

Router-0#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

 

     10.0.0.0/29 is subnetted, 1 subnets

C       10.1.1.0 is directly connected, FastEthernet0/1

C    192.168.0.0/24 is directly connected, FastEthernet0/0

S    192.168.1.0/24 [1/0] via 10.1.1.2 

        建立回到192.168.0.0/255.255.255.0的路由:

Router-1(config)#ip route 192.168.0.0 255.255.255.0 10.1.1.1

路由都是雙向的,有去就會有回,所以相對的也要設定另一端路由

Router-1(config)#exit

Router-1#

%SYS-5-CONFIG_I: Configured from console by console

 

Router-1#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

 

     10.0.0.0/29 is subnetted, 1 subnets

C       10.1.1.0 is directly connected, FastEthernet0/1

S    192.168.0.0/24 [1/0] via 10.1.1.1

C    192.168.1.0/24 is directly connected, FastEthernet0/0

如此192.168.0.1就能夠與192.168.1.1互通

PC>ping 192.168.1.1

 

Pinging 192.168.1.1 with 32 bytes of data:

Reply from 192.168.1.1: bytes=32 time=0ms TTL=126

Reply from 192.168.1.1: bytes=32 time=0ms TTL=126

Reply from 192.168.1.1: bytes=32 time=0ms TTL=126

Reply from 192.168.1.1: bytes=32 time=0ms TTL=126

 

Ping statistics for 192.168.1.1:

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

Approximate round trip times in milli-seconds:

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

創作者介紹
創作者 林作倉 的頭像
林作倉

林作倉

林作倉 發表在 痞客邦 留言(0) 人氣()