本記事対象
telnetを使わずTCPポートを確認する方法が知りたい方
ども。あいしんくいっと(@ithinkitnet)です。
telnetはTCPポートを確認するのに便利なコマンドですが、WindowsServer2012以降は標準で入っておらず、telnetを利用するには機能追加する必要があります。
telnetコマンドを追加してもよいのですが、TCPポート確認のためにわざわざ追加するのは正直面倒です。
そんな時はpowershellコマンドの「Test-NetConnection」を使うと簡単にTCPポートの確認が可能です。
このTest-NetConnectionコマンドはOSに標準搭載されています!
注意
ただしtelnet同様、UDPポートの確認は出来ません
試しにSNMPのUDP161番ポートを確認。
やはり、UDPはエラーが。
PS C:\Users\Administrator> Test-NetConnection 192.168.102.56 -port 161
警告: TCP connect to 192.168.102.56:161 failed
実際に使ってみたところ。
HTTPのTCP80番ポートはリッスン、SNMPのUDP161番ポートはエラー。
「Test-NetConnection」コマンドの使い方
「Test-NetConnection」の使い方は簡単。
telnetと同様にTCPポートの確認が可能です。むしろ、telnetよりも若干高機能かも?
例えば、お馴染みHTTPのポート80番をチェックした場合。
Test-NetConnectionで確認
PS C:\Users\Administrator> Test-NetConnection 192.168.11.100 -port 80
ComputerName : 192.168.11.100
RemoteAddress : 192.168.11.100
RemotePort : 80
InterfaceAlias : Onboard LAN ポート 1
SourceAddress : 192.168.11.200
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : True
ポート確認程度なら、Test-NetConnectionで十分。
◾️コマンドヘルプ
名前
Test-NetConnection
概要
Displays diagnostic information for a connection.
構文
Test-NetConnection [[-ComputerName]] [-CommonTCPPort] [-InformationLevel ] []
Test-NetConnection [[-ComputerName] ] [-Hops ] [-InformationLevel ] [-TraceRoute] []
Test-NetConnection [[-ComputerName] ] [-InformationLevel ] -Port []
説明
The Test-NetConnection cmdlet displays diagnostic information for a connection. The output includes the results of
a DNS lookup, a listing of IP interfaces, an option to test a TCP connection, IPsec rules, and confirmation of conn
ection establishment.
Test-NetConnection
概要
Displays diagnostic information for a connection.
構文
Test-NetConnection [[-ComputerName]
The Test-NetConnection cmdlet displays diagnostic information for a connection. The output includes the results of
a DNS lookup, a listing of IP interfaces, an option to test a TCP connection, IPsec rules, and confirmation of conn
ection establishment.
ポート確認程度なら標準搭載されてる「Test-NetConnection」で済ませてしまうのが楽なのでオススメです。
ithinkit
telnetはポート確認だけでなく、メール送信出来たりするので便利なんですけどねー。
以上、あいしんくいっとでした(^◇^)