source interfaceを指定してのpingコマンドの実行方法
- カテゴリ:
- Cisco
pingコマンドでネットワークの疎通を確認しますが、sourceを利用して送信元のインターフェイスやIPアドレスを指定することが出来ます。
R1#ping 192.168.1.1 ? 〜略〜 source specify source address or name 〜略〜 |
現在R1とR2は12.12.12.0/24で直接接続されています。
R1#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 12.12.12.1 YES manual up up FastEthernet0/1 1.1.1.1 YES manual up up Loopback0 17.17.1.1 YES NVRAM up up R2#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0/0 12.12.12.2 YES manual up up Loopback0 17.17.2.2 YES NVRAM up up |
まずR2のF0/0へpingを実行します。この時点ではルーティングの設定はまだありません。
R1#ping 12.12.12.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.12.12.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/12 ms |
ここでEIGRPを設定します。
R1(config)#router eigrp 100 R1(config-router)#no auto-summary R1(config-router)#network 17.17.1.1 0.0.0.0 R1(config-router)#network 12.12.12.1 0.0.0.0 R2(config)#router eigrp 100 R2(config-router)#no auto-summary R2(config-router)#network 17.17.2.2 0.0.0.0 R2(config-router)#network 12.12.12.2 0.0.0.0 |
R1がR2とネイバーを確立したことを確認します。
R1#show ip eigrp neighbors IP-EIGRP neighbors for process 100 H Address Interface Hold Uptime SRTT RTO Q Seq (sec) (ms) Cnt Num 0 12.12.12.2 Fa0/0 12 00:00:12 8 300 0 4 |
この時点でのルーティングテーブルを確認します。
R1#show ip route eigrp 17.0.0.0/24 is subnetted, 2 subnets D 17.17.2.0 [90/156160] via 12.12.12.2, 00:02:07, FastEthernet0/0 R2#show ip route eigrp 17.0.0.0/24 is subnetted, 2 subnets D 17.17.1.0 [90/156160] via 12.12.12.1, 00:02:16, FastEthernet0/0 |
R1からpingコマンドを実行する前に、R2でdebugを設定します。
R2#debug ip icmp ICMP packet debugging is on |
ここでpingをR2のLo0に対して実行します。
R1#ping 17.17.2.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 17.17.2.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/8/16 ms |
この時、R2では下記のようなログが表示されます。dstが12.12.12.1であることから、pingはF0/0をソースとして実行されたことが分かります。
R2# Feb 23 06:07:08.119: ICMP: echo reply sent, src 17.17.2.2, dst 12.12.12.1 Feb 23 06:07:08.135: ICMP: echo reply sent, src 17.17.2.2, dst 12.12.12.1 |
次にsourceを利用して実行します。ここではLo0(17.17.1.1)を指定しました。
R1#ping 17.17.2.2 source loopback 0 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 17.17.2.2, timeout is 2 seconds: Packet sent with a source address of 17.17.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/7/8 ms |
R2のログは下記のようになります。確かに17.17.1.1を利用していることが分かります。
Feb 23 06:09:42.091: ICMP: echo reply sent, src 17.17.2.2, dst 17.17.1.1 Feb 23 06:09:42.111: ICMP: echo reply sent, src 17.17.2.2, dst 17.17.1.1 |
では次にF0/1(1.1.1.1)を利用して実行しますが、失敗します。
R1#ping 17.17.2.2 source fastEthernet 0/1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 17.17.2.2, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 ..... Success rate is 0 percent (0/5) |
何故でしょうか。R2では下記のようなログが表示されていることから、パケットが届いており、replyを1.1.1.1に対して送っていることが分かります。
Feb 23 06:15:32.807: ICMP: echo reply sent, src 17.17.2.2, dst 1.1.1.1 Feb 23 06:15:34.811: ICMP: echo reply sent, src 17.17.2.2, dst 1.1.1.1 |
pingが成功しない理由は、R2のルーティングテーブルに1.1.1.1が載っていないからです。
R2#show ip route 1.1.1.1 % Network not in table |
ここでR1のEIGRPでF0/1を有効にします。
R1(config)#router eigrp 100 R1(config-router)#network 1.1.1.1 0.0.0.0 |
これによりR2のルーティングテーブルに1.1.1.1が載りました。
R2#show ip route 1.1.1.1 Routing entry for 1.1.1.0/24 Known via "eigrp 100", distance 90, metric 30720, type internal 〜略〜 |
先程のpingが無事実行出来ます。
R1#ping 17.17.2.2 source fastEthernet 0/1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 17.17.2.2, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 8/8/12 ms |
このように、pingが通らない時にはping sourceとdebug ip icmpを利用することで問題点を見つけやすくなります。
コメント