スタティックルートについて
管理者が経路情報を手動で設定するルートの事です。
少し話が反れますが、、
ルーティングテーブル上に存在しない外部のネットワークに通信は行えません。
ルーターはルーティングテーブルに経路情報が登録されていない場合は、データを破棄してしまいます。
学習ついでに、Packet Tracerで環境構築をしてみます。
Packet Tracerを使用して、実際に検証
今回は、192.168.0.1
から192.168.1.1
に通信する事を目的にします。
下記のような構成で検証します。
ルーティングテーブルの状態
#Router1のルーティングテーブル
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/29 is directly connected, GigabitEthernet0/1
L 10.0.0.1/32 is directly connected, GigabitEthernet0/1
192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.0.0/24 is directly connected, GigabitEthernet0/0
L 192.168.0.254/32 is directly connected, GigabitEthernet0/0
#Router3のルーティングテーブル
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/29 is directly connected, GigabitEthernet0/1
L 10.0.0.2/32 is directly connected, GigabitEthernet0/1
192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.0.0/24 is directly connected, GigabitEthernet0/0
L 192.168.0.254/32 is directly connected, GigabitEthernet0/0
現時点の設定で、PC0 → PC1 に通信が行えるかを確認します。
失敗してしまいます。
PC0 → PC1
C:\>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.0.254: Destination host unreachable.
Reply from 192.168.0.254: Destination host unreachable.
Reply from 192.168.0.254: Destination host unreachable.
Request timed out.
Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
理由は、Router1にPC1の経路情報が設定されていない
また Router3にPC0の経路情報が設定されていない
事が原因です。
ここで手動(スタティックルート
)で、経路情報の設定を行います。
ip route network mask ip-address | interface
で、スタティックルート
の設定を行えます。
コマンド実行後に再度ルーティングテーブルを確認したところ、スタティックルート
が反映されている事を確認しました。
経路情報の設定
# Router1にスタティックルートの設定
Router(config)#ip route 192.168.1.0 255.255.255.0 10.0.0.2
Router# show ip route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/29 is directly connected, GigabitEthernet0/1
L 10.0.0.1/32 is directly connected, GigabitEthernet0/1
192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.0.0/24 is directly connected, GigabitEthernet0/0
L 192.168.0.254/32 is directly connected, GigabitEthernet0/0
S 192.168.1.0/24 [1/0] via 10.0.0.2
# Router3にスタティックルートの設定
Router(config)#ip route 192.168.0.0 255.255.255.0 10.0.0.1
Router# show ip route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/29 is directly connected, GigabitEthernet0/1
L 10.0.0.2/32 is directly connected, GigabitEthernet0/1
S 192.168.0.0/24 [1/0] via 10.0.0.1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.254/32 is directly connected, GigabitEthernet0/0
この状態で、PC0 → PC1に通信してみます。
無事通信出来る事を確認致しました。
PC0 → PC1
C:\>ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes=32 time<1ms TTL=126
Reply from 192.168.1.1: bytes=32 time<1ms TTL=126
Reply from 192.168.1.1: bytes=32 time<1ms TTL=126
Reply from 192.168.1.1: bytes=32 time<1ms 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
以上で、終了致します。