Windowsのnetstatコマンドを試してみた
ネットワーク接続を表示するための、netstatコマンドを試してみました。
目次
接続を表示する
コマンド
netstat -a
実行結果
Active Connections Proto Local Address Foreign Address State TCP LaVie-GA:1053 localhost:3681 TIME_WAIT TCP LaVie-GA:1053 localhost:3682 TIME_WAIT TCP LaVie-GA:1053 localhost:3686 TIME_WAIT TCP LaVie-GA:1053 localhost:3689 TIME_WAIT TCP LaVie-GA:2970 localhost:2971 ESTABLISHED TCP LaVie-GA:2971 localhost:2970 ESTABLISHED TCP LaVie-GA:2972 localhost:2973 ESTABLISHED TCP LaVie-GA:2973 localhost:2972 ESTABLISHED TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT
すべての接続とリッスンポートを表示する
コマンド
netstat -a
実行結果
Active Connections Proto Local Address Foreign Address State TCP LaVie-GA:epmap LaVie-GA:0 LISTENING TCP LaVie-GA:microsoft-ds LaVie-GA:0 LISTENING TCP LaVie-GA:990 LaVie-GA:0 LISTENING TCP LaVie-GA:2425 LaVie-GA:0 LISTENING TCP LaVie-GA:2869 LaVie-GA:0 LISTENING TCP LaVie-GA:3389 LaVie-GA:0 LISTENING TCP LaVie-GA:1027 LaVie-GA:0 LISTENING TCP LaVie-GA:1053 LaVie-GA:0 LISTENING TCP LaVie-GA:1053 localhost:3525 TIME_WAIT TCP LaVie-GA:1053 localhost:3526 TIME_WAIT TCP LaVie-GA:1053 localhost:3530 TIME_WAIT TCP LaVie-GA:1053 localhost:3532 TIME_WAIT TCP LaVie-GA:2970 localhost:2971 ESTABLISHED TCP LaVie-GA:2971 localhost:2970 ESTABLISHED TCP LaVie-GA:2972 localhost:2973 ESTABLISHED TCP LaVie-GA:2973 localhost:2972 ESTABLISHED TCP LaVie-GA:5152 LaVie-GA:0 LISTENING TCP LaVie-GA:5679 LaVie-GA:0 LISTENING TCP LaVie-GA:7438 LaVie-GA:0 LISTENING TCP LaVie-GA:netbios-ssn LaVie-GA:0 LISTENING TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT UDP LaVie-GA:microsoft-ds *:* UDP LaVie-GA:isakmp *:* UDP LaVie-GA:ms-sql-m *:* UDP LaVie-GA:2425 *:* UDP LaVie-GA:4500 *:* UDP LaVie-GA:30020 *:* UDP LaVie-GA:ntp *:* UDP LaVie-GA:1900 *:* UDP LaVie-GA:ntp *:* UDP LaVie-GA:netbios-ns *:* UDP LaVie-GA:netbios-dgm *:* UDP LaVie-GA:1900 *:*
指定したプロトコルの接続を表示する
指定したプロトコルの接続を表示します。なお、プロトコルとしてTCP、UDP、TCPv6またはUDPv6を指定可能です。
実行結果
Active Connections Proto Local Address Foreign Address State TCP LaVie-GA:1053 localhost:3535 TIME_WAIT TCP LaVie-GA:1053 localhost:3536 TIME_WAIT TCP LaVie-GA:1053 localhost:3540 TIME_WAIT TCP LaVie-GA:1053 localhost:3542 TIME_WAIT TCP LaVie-GA:2970 localhost:2971 ESTABLISHED TCP LaVie-GA:2971 localhost:2970 ESTABLISHED TCP LaVie-GA:2972 localhost:2973 ESTABLISHED TCP LaVie-GA:2973 localhost:2972 ESTABLISHED TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT
アドレスとポートを数値形式で表示する
コマンド
netstat -n
実行結果
Active Connections Proto Local Address Foreign Address State TCP 127.0.0.1:1053 127.0.0.1:3535 TIME_WAIT TCP 127.0.0.1:1053 127.0.0.1:3536 TIME_WAIT TCP 127.0.0.1:1053 127.0.0.1:3540 TIME_WAIT TCP 127.0.0.1:1053 127.0.0.1:3542 TIME_WAIT TCP 127.0.0.1:2970 127.0.0.1:2971 ESTABLISHED TCP 127.0.0.1:2971 127.0.0.1:2970 ESTABLISHED TCP 127.0.0.1:2972 127.0.0.1:2973 ESTABLISHED TCP 127.0.0.1:2973 127.0.0.1:2972 ESTABLISHED TCP 192.168.1.18:1276 61.25.1.75:80 CLOSE_WAIT
接続を所有するプロセスIDを表示する
コマンド
netstat -o
実行結果
Active Connections Proto Local Address Foreign Address State PID TCP LaVie-GA:1053 localhost:3535 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3536 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3540 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3542 TIME_WAIT 0 TCP LaVie-GA:2970 localhost:2971 ESTABLISHED 4380 TCP LaVie-GA:2971 localhost:2970 ESTABLISHED 4380 TCP LaVie-GA:2972 localhost:2973 ESTABLISHED 4380 TCP LaVie-GA:2973 localhost:2972 ESTABLISHED 4380 TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT 1884
接続やリッスンポートを作成したプログラムを表示する
コマンド
netstat -b
実行結果
Active Connections Proto Local Address Foreign Address State PID TCP LaVie-GA:1053 localhost:3535 ESTABLISHED 3604 [ccApp.exe] TCP LaVie-GA:2970 localhost:2971 ESTABLISHED 4380 [thunderbird.exe] TCP LaVie-GA:2971 localhost:2970 ESTABLISHED 4380 [thunderbird.exe] TCP LaVie-GA:2972 localhost:2973 ESTABLISHED 4380 [thunderbird.exe] TCP LaVie-GA:2973 localhost:2972 ESTABLISHED 4380 [thunderbird.exe] TCP LaVie-GA:3535 localhost:1053 ESTABLISHED 4380 [thunderbird.exe] TCP LaVie-GA:3538 pop03.mail.vip.bbt.yahoo.co.jp:pop3 ESTABLISHED 3604 [ccApp.exe] TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT 1884 [jusched.exe] TCP LaVie-GA:3537 rv-in-f111.google.com:995 LAST_ACK 4380 [thunderbird.exe] TCP LaVie-GA:1053 localhost:3530 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3536 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3525 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3532 TIME_WAIT 0
接続やリッスンポートを作成したプログラムとコンポーネントを表示する
コマンド
netstat -b -v
実行結果
Active Connections Proto Local Address Foreign Address State PID TCP LaVie-GA:2970 localhost:2971 ESTABLISHED 4380 C:\WINDOWS\system32\WS2_32.dll C:\Program Files\Mozilla Thunderbird\nspr4.dll C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe [thunderbird.exe] TCP LaVie-GA:2971 localhost:2970 ESTABLISHED 4380 C:\WINDOWS\system32\mswsock.dll C:\WINDOWS\system32\WS2_32.dll C:\Program Files\Mozilla Thunderbird\nspr4.dll C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll [thunderbird.exe] TCP LaVie-GA:2972 localhost:2973 ESTABLISHED 4380 C:\WINDOWS\system32\WS2_32.dll C:\Program Files\Mozilla Thunderbird\nspr4.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\js3250.dll [thunderbird.exe] TCP LaVie-GA:2973 localhost:2972 ESTABLISHED 4380 C:\WINDOWS\system32\mswsock.dll C:\WINDOWS\system32\WS2_32.dll C:\Program Files\Mozilla Thunderbird\nspr4.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\xpcom_core.dll C:\Program Files\Mozilla Thunderbird\thunderbird.exe C:\Program Files\Mozilla Thunderbird\js3250.dll [thunderbird.exe] TCP LaVie-GA:1276 a61-25-1-75.deploy.akamaitechnologies.com:http CLOSE_WAIT 1884 C:\WINDOWS\system32\WS2_32.dll C:\WINDOWS\system32\WININET.dll [jusched.exe] TCP LaVie-GA:1053 localhost:3550 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3545 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3551 TIME_WAIT 0 TCP LaVie-GA:1053 localhost:3546 TIME_WAIT 0
イーサネットの統計を表示する
コマンド
netstat -e
実行結果
Interface Statistics Received Sent Bytes 951983746 81772991 Unicast packets 1775749 1546354 Non-unicast packets 3718 649 Discards 0 0 Errors 0 3 Unknown protocols 0
プロトコルごとの統計を表示する
コマンド
netstat -s
実行結果
IPv4 Statistics Packets Received = 2473119 Received Header Errors = 0 Received Address Errors = 2306 Datagrams Forwarded = 0 Unknown Protocols Received = 0 Received Packets Discarded = 1963 Received Packets Delivered = 2471156 Output Requests = 2239246 Routing Discards = 0 Discarded Output Packets = 0 Output Packet No Route = 0 Reassembly Required = 0 Reassembly Successful = 0 Reassembly Failures = 0 Datagrams Successfully Fragmented = 0 Datagrams Failing Fragmentation = 0 Fragments Created = 0 ICMPv4 Statistics Received Sent Messages 29 30 Errors 0 0 Destination Unreachable 0 1 Time Exceeded 0 0 Parameter Problems 0 0 Source Quenches 0 0 Redirects 0 0 Echos 0 29 Echo Replies 29 0 Timestamps 0 0 Timestamp Replies 0 0 Address Masks 0 0 Address Mask Replies 0 0 TCP Statistics for IPv4 Active Opens = 2691 Passive Opens = 168 Failed Connection Attempts = 15 Reset Connections = 251 Current Connections = 10 Segments Received = 2462955 Segments Sent = 2232325 Segments Retransmitted = 74 UDP Statistics for IPv4 Datagrams Received = 8167 No Ports = 33 Receive Errors = 0 Datagrams Sent = 6768
指定したプロトコルの統計を表示する
指定したプロトコルの統計を表示します。なお、プロトコルとしてIP、IPv6、ICMP、ICMPv6、TCP、TCPv6、UDPまたはUDPv6を指定可能です。
コマンド
netstat -s -p ICMP
実行結果
ICMPv4 Statistics Received Sent Messages 29 30 Errors 0 0 Destination Unreachable 0 1 Time Exceeded 0 0 Parameter Problems 0 0 Source Quenches 0 0 Redirects 0 0 Echos 0 29 Echo Replies 29 0 Timestamps 0 0 Timestamp Replies 0 0 Address Masks 0 0 Address Mask Replies 0 0
ルーティングテーブルを表示する
netstatコマンドでもルーティングテーブルを表示できます。表示内容はroute printコマンドと同じです。
コマンド
netstat -r
実行結果
Route Table =========================================================================== Interface List 0x1 ........................... MS TCP Loopback interface 0x2 ...00 16 6f c1 81 90 ...... Intel(R) PRO/Wireless 2200BG Network Connection - パケット スケジューラ ミニポート 0x3 ...00 0d 5e 32 72 f1 ...... Intel(R) PRO/100 VE Network Connection - パケット スケジューラ ミニポート 0x10005 ...00 03 7a 43 06 0f ...... Bluetooth Personal Area Network from TOSHIBA - パケット スケジューラ ミニポート =========================================================================== =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.18 1 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 192.168.1.0 255.255.255.0 192.168.1.18 192.168.1.18 1 192.168.1.18 255.255.255.255 127.0.0.1 127.0.0.1 1 192.168.1.255 255.255.255.255 192.168.1.18 192.168.1.18 1 224.0.0.0 240.0.0.0 192.168.1.18 192.168.1.18 1 255.255.255.255 255.255.255.255 192.168.1.18 192.168.1.18 1 255.255.255.255 255.255.255.255 192.168.1.18 3 1 255.255.255.255 255.255.255.255 192.168.1.18 10005 1 Default Gateway: 192.168.1.1 =========================================================================== Persistent Routes: None