🚀

【Windows】ネットワーク障害発生時に確認すべきコマンド②

に公開

前回サーバ内部で確認するコマンド をまとめた。

今回は 外部からの疎通確認 を行う際に使うコマンドを整理する。


① ping

ICMP レベルの疎通確認

ping example.com

主なオプション

  • -n <回数>:送信回数指定
  • -t:連続送信
  • -l <サイズ>:パケットサイズ指定
ping -n 4 example.com

出力例

> ping -n 4 example.com

example.com [203.0.113.10] に ping を送信しています 32 バイトのデータ:
203.0.113.10 からの応答: バイト数 =32 時間 =5ms TTL=117
203.0.113.10 からの応答: バイト数 =32 時間 =6ms TTL=117
203.0.113.10 からの応答: バイト数 =32 時間 =5ms TTL=117
203.0.113.10 からの応答: バイト数 =32 時間 =5ms TTL=117

確認ポイント

  • 宛先に到達できているか
  • 応答時間が極端に遅くないか
  • パケットロスが発生していないか

※ ICMP が遮断されている環境では失敗する場合がある
(ping 不可=通信不可とは限らない)


② nslookup

DNS 名前解決の確認

nslookup example.com

主なオプション

  • set type=A:A レコード指定
  • server <IP>:DNS サーバ指定
nslookup
> server 8.8.8.8
> set type=A
> example.com

DNS サーバを直接指定する場合:

nslookup www.example.com 8.8.8.8

出力例

サーバー:  dns.example
Address:  8.8.8.8

権限のない回答:
名前:    www.example.com
Addresses:  203.0.113.20
           203.0.113.21

確認ポイント

  • 名前解決ができているか
  • 期待した IP が返ってきているか
  • 想定外の IP(別環境・別系統)に解決されていないか
  • DNS サーバ自体が応答しているか

③ Test-NetConnection

TCP ポート疎通確認(PowerShell)

Test-NetConnection example.com -Port 443

主なオプション

  • -Port:確認する TCP ポート
  • -InformationLevel Quiet:True / False のみ出力
Test-NetConnection example.com -Port 443 -InformationLevel Quiet

出力例

ComputerName     : example.com
RemoteAddress    : 203.0.113.53
RemotePort       : 443
SourceAddress    : 192.168.xxx.xxx
TcpTestSucceeded : True

確認ポイント

  • OK(TcpTestSucceeded : True)の場合

    • TCP レベルでは対象ポートまで到達できている
    • FW / ルーティング / ポート閉塞の可能性は低い
  • NG(False)の場合

    • ポートが閉じている
    • FW / セキュリティグループ / ルーティングを疑う
    • サービス未起動の可能性もある

TCP 専用
UDP の疎通確認は不可(DNS / QUIC 等は別手段が必要)


④ tracert

通信経路の確認

tracert example.com

主なオプション

  • -d:名前解決を省略(高速化)
  • -h <数>:最大ホップ数指定
tracert -d example.com

出力例(マスク済み)

  1   1 ms   2 ms   1 ms  192.168.xxx.1
  2   4 ms   3 ms   4 ms  198.51.100.10
  3   *      *      *

確認ポイント

  • どのネットワーク区間まで到達しているか
  • 特定のホップで遅延・応答消失していないか
  • * は FW による ICMP 制限の可能性あり

ポート指定は不可
(ICMP ベースの経路確認)


補足:PowerShell の場合(Test-NetConnection -TraceRoute)

PowerShell では tracert 相当として
Test-NetConnection -TraceRoute を使用できる。

Test-NetConnection example.com -TraceRoute

出力例

Test-NetConnection google.com -TraceRoute


ComputerName           : google.com
RemoteAddress          : 142.250.194.78
InterfaceAlias         : Wi-Fi
SourceAddress          : 192.168.x.x
PingSucceeded          : True
PingReplyDetails (RTT) : 6 ms
TraceRoute             : 192.168.xxx.x
               198.51.100.10

補足ポイント

  • tracert と同様に 経路確認が可能

  • 出力が PowerShell オブジェクト

    • ログ化・自動判定に向いている
  • ポート指定は不可

    • TCP/UDP の経路確認ではない

⑤ Invoke-WebRequest

HTTP / HTTPS レベルの疎通確認

Invoke-WebRequest https://example.com -UseBasicParsing

主なオプション

  • -TimeoutSec:タイムアウト秒数指定
  • -Method:GET / POST 指定
Invoke-WebRequest https://example.com -TimeoutSec 10

出力例(抜粋・マスク済み)

StatusCode        : 200
StatusDescription : OK
・・・

確認ポイント

  • DNS → TCP → TLS → HTTP まで一通り成功しているか
  • ステータスコードでアプリケーション層の状態を判断

参考資料

Discussion