windowsでポートの疎通を確認する方法をご紹介します。
「Test-NetConnection」を使用します。
以下のように実行します。
1 |
Test-NetConnection "ターゲット" -port "ポート" |
接続に成功した場合の例として、googleに接続してみました。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
PS C:\> Test-NetConnection google.com -port 443 ComputerName : google.com RemoteAddress : 172.217.31.142 RemotePort : 443 InterfaceAlias : Wi-Fi SourceAddress : 192.168.0.4 TcpTestSucceeded : True PS C:\> |
続いて、失敗する場合の例を見てみます。
kamotora.netのポート500に接続してみます。このポート番号は空いていません。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
PS C:\Users\yanase> Test-NetConnection kamotora.net -port 500 警告: TCP connect to (140.83.34.244 : 500) failed ComputerName : kamotora.net RemoteAddress : 140.83.34.244 RemotePort : 500 InterfaceAlias : Wi-Fi SourceAddress : 192.168.0.4 PingSucceeded : True PingReplyDetails (RTT) : 5 ms TcpTestSucceeded : False PS C:\Users\yanase> |
「failed」と表示されているのがわかると思います。
なお、Test-NetConnectionですが、接続先がICMPを閉じている場合は少し待たせれてしまいます。
覚えておきましょう!