If you just wish to see TCP ports in use on a Microsoft Windows system, you can issue the
netstat -a -p TCP
command at a command prompt.
The -a
parameter specifies all connections and listening
ports should be displayed while the -p
parameter can be
used to select a protocol from TCP, UDP, TCPv6, or UDPv6. If used with the
-s
option to display per-protocol statistics, the protocol
argument may be any of: IP, IPv6,
ICMP, ICMPv6, TCP, TCPv6, UDP, or
UDPv6. If you only wish to view IPv6 TCP ports in use,
you can use netstat -a -p TCPv6
. If you only wish to
see currently established connections, you can pipe the output of
the netstat
command to the find
command. E.g.,
netstat -a -p TCP | find "ESTABLISHED"
. Or, if you wished to
see all of the TCP ports on which the system was listening for a connection,
you could use netstat -a -p TCP | find "LISTENING"
. If you
wanted to see connections to a particular port, e.g., 22, for Secure
Shell (SSH) connections, you could use netstat -a | find ":ssh"
, which would show the IP addresses of the remote systems connected
via SSH, or netstat -a | find ":https"
for
HTTPS connections to web sites. If you wished to see host names rather than IP addresses, you could
add the -f
option, which displays a
Fully Qualified Domain Name
(FQDN) instead of an IP address for a remote system. E.g.,
netstat -a -f | find ":https"
. Since SSH, HTTP, and HTTPS
use TCP rather than UDP transmissions, you don't need to add the
-p
parameter.