私は、IP アドレスが有効で使用可能かどうかをテストする Reachability クラスをプログラミングしています。クラスが正常に動作するかどうかをテストするためのユニット テストを記述したところ、問題が発生しました。ネットワーク内では到達不可能だと思っていた IP アドレス 192.168.1.255 でテストしましたが、IsReachable = true でした。えっ... どうしてこんなことが起きるのでしょうか?
ベースラインができました。Windows に付属の「ping」アプリケーションを使用できます。これがそのテストの結果です。
# ping 192.168.1.255
Pinging 192.168.1.255 with 32 bytes of data:
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time<1ms TTL=64
Reply from 192.168.1.200: bytes=32 time=1ms TTL=64
Ping statistics for 192.168.1.255:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
さらに奇妙になる
# ping 192.168.1.253
Pinging 192.168.1.253 with 32 bytes of data:
Reply from 192.168.1.27: Destination host unreachable.
Reply from 192.168.1.25: Destination host unreachable.
Reply from 137.224.244.1: Destination net unreachable.
Reply from 137.224.244.1: Destination net unreachable.
Ping statistics for 192.168.1.253:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
ここで何が起こっているのでしょうか? この結果が何を意味するのか誰か説明してもらえますか?
編集して追加された IPCONFIG
ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : DESKTOP-CB16LLI
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : wurnet.nl
home
Ethernet adapter Ethernet 3:
Connection-specific DNS Suffix . : wurnet.nl
Description . . . . . . . . . . . : NCP Secure Client Virtual NDIS6 Adapter
Physical Address. . . . . . . . . : 02-00-AD-4F-70-18
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 137.224.245.97(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : vrijdag 30 maart 2018 08:20:26
Lease Expires . . . . . . . . . . : donderdag 17 mei 2018 21:25:51
Default Gateway . . . . . . . . . :
DHCP Server . . . . . . . . . . . : 137.224.245.98
DNS Servers . . . . . . . . . . . : 10.90.3.31
10.91.3.31
NetBIOS over Tcpip. . . . . . . . : Enabled
Ethernet adapter Ethernet 1:
Connection-specific DNS Suffix . : home
Description . . . . . . . . . . . : Surface Ethernet Adapter
Physical Address. . . . . . . . . : C4-9D-ED-E8-5D-1E
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.27(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : vrijdag 30 maart 2018 08:12:39
Lease Expires . . . . . . . . . . : zaterdag 31 maart 2018 08:12:50
Default Gateway . . . . . . . . . : 192.168.1.254
DHCP Server . . . . . . . . . . . : 192.168.1.254
DNS Servers . . . . . . . . . . . : 192.168.1.254
NetBIOS over Tcpip. . . . . . . . : Enabled
Wireless LAN adapter Local Area Connection* 1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter
Physical Address. . . . . . . . . : BE-83-85-E7-C5-48
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Ethernet adapter Bluetooth Network Connection:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network)
Physical Address. . . . . . . . . : BC-83-85-E7-C4-4A
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : home
Description . . . . . . . . . . . : Marvell AVASTAR Wireless-AC Network Controller
Physical Address. . . . . . . . . : BC-83-85-E7-C4-49
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::49ca:6fd:8fa4:a099%3(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.1.25(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : vrijdag 30 maart 2018 08:12:49
Lease Expires . . . . . . . . . . : zaterdag 31 maart 2018 08:13:08
Default Gateway . . . . . . . . . : 192.168.1.254
DHCP Server . . . . . . . . . . . : 192.168.1.254
DHCPv6 IAID . . . . . . . . . . . : 79463301
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-22-4C-14-89-C4-9D-ED-E8-5D-1E
DNS Servers . . . . . . . . . . . : fe80::2aff:3eff:fe3d:f5%3
192.168.1.254
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter Local Area Connection* 11:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft Teredo Tunneling Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
編集 上記のpingはVPN接続が開いているときのものです。以下はVPN接続が閉じているときのものです。
ping 192.168.1.253
Pinging 192.168.1.253 with 32 bytes of data:
Reply from 192.168.1.27: Destination host unreachable.
Reply from 192.168.1.27: Destination host unreachable.
Reply from 192.168.1.27: Destination host unreachable.
Reply from 192.168.1.27: Destination host unreachable.
答え1
0
これらは255
、255.255.255.0 サブネット ネットワーク上のマシンの有効なアドレスではありません。
255 は「ブロードキャスト」アドレスであり、0 は「ネットワーク アドレス」です。
関連資料IP アドレスはなぜ 0 または 255 で始まらないのですか?回答は、幅広い IP アドレスのケースに対応していますが、このルールはサブネット化されたアドレスにも適用されるため、255.255.255.0 サブネットの場合、最初と最後の IP は予約されています。
...の ping に関しては、.253
最初の ping では基本的に、すべてのネットワーク アダプタに対して、ホストへのルートがあるかどうかを問い合わせます。
2件のケースでは、Destination host unreachable.
基本的に「ここにあればお知らせしますが、何らかの理由でアクセスできません」という返信がありました。
もっと奇妙なのは、VPNネットワークゲートウェイです。Destination net unreachable.
この場合、サブネット化やその他の要因により、通信する方法がまったくないと言っています。どれでもそのネットワーク上のマシン。
最終的な ping は、予想どおりのようです。ローカル ネットワーク アダプタは、アドレスに到達できないことを通知しているだけです。
答え2
ICMP プロトコルは、(この場合) IPv4 上で直接動作します。ユニキャスト UDP や TCP とは異なるルーティング ルールを持っています。基本的に、ICMP パケットを見たホストは誰でも応答できます (嘘をつくことさえできます)。
したがって、受信パケット数に表示されるのは、宛先からの応答だけではありません。