netstat
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Windows commands reference
On Windows, Linux, macOS 11 Sigma rules name it File netstat.exe
Windows
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Used without parameters, this command displays active TCP connections. IMPORTANT: This command is available only if the Internet Protocol (TCP/IP) protocol is installed as a component in the properties of a network adapter in Network Connections.
netstat [-a] [-b] [-e] [-n] [-o] [-p <Protocol>] [-q] [-r] [-s] [<interval>]netstat -e -snetstat -s -p tcp udpnetstat -o 5netstat -n -onetstat -anobq
-aDisplays all active TCP connections and the TCP and UDP ports on which the computer is listening.-eDisplays Ethernet statistics, such as the number of bytes and packets sent and received. This parameter can be combined with -s.-nDisplays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names.-oDisplays active TCP connections and includes the process ID (PID) for each connection. You can find the application based on the PID on the Processes tab in Windows Task Manager. This parameter can be combined with -a, -n, and -p.-p <Protocol>Shows connections for the protocol specified by Protocol. In this case, the Protocol can be tcp, udp, tcpv6, or udpv6. If this parameter is used with -s to display statistics by protocol, Protocol can be tcp, udp, icmp, ip, tcpv6, udpv6, icmpv6, or ipv6.-qDisplays all connections, listening ports, and bound nonlistening TCP ports. Bound nonlistening ports may or may not be associated with an active connection.-sDisplays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. If the IPv6 protocol is installed, statistics are shown for the TCP over IPv6, UDP over IPv6, ICMPv6, and IPv6 protocols. The -p parameter can be used to specify a set of protocols.-rDisplays the contents of the IP routing table. This is equivalent to the route print command.<interval>Redisplays the selected information every interval seconds. Press CTRL+C to stop the redisplay. If this parameter is omitted, this command prints the selected information only once./?Displays help at the command prompt.Linux
Display networking information. Default is netstat -tuwx
netstat [-pWrxwutneal]
-rRouting table-aAll sockets (not just connected)-lListening server sockets-tTCP sockets-uUDP sockets-wRaw sockets-xUnix sockets-eExtended info-nDon't resolve names-WWide display-pShow PID/program name of socketsSeveral platforms
Display network-related information such as open connections, open socket ports, etc.
List all ports
netstat --allIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
List all listening ports
netstat --listeningIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
List listening TCP ports
netstat --tcpIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
Display PID and program names
netstat --programIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
List information continuously
netstat --continuousIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
List routes and do not resolve IP addresses to hostnames
netstat --route --numericIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
List listening TCP and UDP ports (+ user and process if you're root)
netstat --tcp --udp --listening --program --numeric --extendIdentifyTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
macOS
Display network-related information such as open connections, open socket ports, etc.
Display the PID and program name listening on a specific protocol
netstat -p protocolIdentify-pShow PID/program name of sockets toyboxTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
Print the routing table and do not resolve IP addresses to hostnames
netstat -nrIdentify-nDon't resolve names toybox-rRouting table toyboxTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
Print the routing table of IPv4 addresses
netstat -nr -f inetIdentify-nDon't resolve names toybox-rRouting table toyboxTrips 3 Sigma rules: lowSystem Network Connections Discovery - Linux by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Connections Discovery - MacOs by Daniil Yugoslavskiy, oscd.community; informationalSystem Network Discovery - Linux by Ömer Günal and remotephone, oscd.community
Windows
Display active TCP connections, ports on which the computer is listening, network adapter statistics, the IP routing table, IPv4 statistics, and IPv6 statistics.
Display active TCP connections
netstatIdentifyDisplay all active TCP connections and the TCP and UDP ports on which the computer is listening
netstat -aIdentify-aDisplays all active TCP connections and the TCP and UDP ports on which the computer is listening. Windows commands referenceDisplay network adapter statistics, such as the number of bytes and packets sent and received
netstat -eIdentify-eDisplays Ethernet statistics, such as the number of bytes and packets sent and received. Windows commands referenceDisplay active TCP connections and express addresses and port numbers numerically
netstat -nIdentify-nDisplays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names. Windows commands referenceDisplay active TCP connections and include the process ID (PID) for each connection
netstat -oIdentify-oDisplays active TCP connections and includes the process ID (PID) for each connection. Windows commands referenceDisplay the contents of the IP routing table
netstat -rIdentify-rDisplays the contents of the IP routing table. Windows commands referenceDisplay statistics by protocol
netstat -sIdentify-sDisplays statistics by protocol. Windows commands referenceDisplay a list of currently open ports and related IP addresses
netstat -anIdentify-aDisplays all active TCP connections and the TCP and UDP ports on which the computer is listening. Windows commands reference-nDisplays active TCP connections, however, addresses and port numbers are expressed numerically and no attempt is made to determine names. Windows commands reference