|
| 1 | +--- |
| 2 | +title: Netstat under Windows |
| 3 | +date: 2025-07-27T10:17:10.288Z |
| 4 | +categories: |
| 5 | +- Network |
| 6 | +- Tutorials |
| 7 | +- Windows |
| 8 | +tags: |
| 9 | +- cmd |
| 10 | +- network |
| 11 | +- tutorials |
| 12 | +- windows |
| 13 | +description: How does Netstat work on Windows? Netstat commands explained simply. |
| 14 | +menu: |
| 15 | + sidebar: |
| 16 | + name: Netstat on Windows at a glance |
| 17 | + identifier: netstat-en |
| 18 | + parent: windows |
| 19 | +lastmode: 2025-07-27T10:19:50.194Z |
| 20 | +keywords: |
| 21 | +- netstat |
| 22 | +preview: ../../../assets/images/posts/windows/netstat-help.png |
| 23 | +hero: /images/posts/windows/netstat-help.png |
| 24 | +--- |
| 25 | +## Display TCP connections and ports in Windows with netstat |
| 26 | +In this article, I would like to introduce you to the command/tool **netstat** in Windows and show you how you can use this command to check or display active TCP connections, open ports, and other statistics such as an IPv4 overview of the Internet protocols IP, TCP, ICMP, and UDP. |
| 27 | +### What do I use the Netstat commands for? |
| 28 | +When analyzing the security of an operating system, it is of course important to know which connections the operating system or installed software establishes to services on the Internet. Furthermore, malware can also be quickly detected by displaying listening ports. The netstat command can be used to list these connections and listening ports. |
| 29 | +### What can I do with the netstat command? |
| 30 | +You can also use the information obtained in this way to analyze connection problems caused by your firewall, server instance, or UTM. This is because even legitimate programs need a connection to the Internet for various services but are blocked by your software or hardware firewall, for example. |
| 31 | +When assessing the security of a system, it is important to know that most attacks on a system are carried out by creating a reverse shell. Since most standard firewalls only monitor traffic/requests from the outside to the inside and generally trust connections from the inside to the outside, attacks via a reverse shell are one of the most commonly used attack scenarios. |
| 32 | +### How does netstat work? |
| 33 | +To use **netstat**, you must first open the command line or start a Powershell instance. |
| 34 | +#### Open the command line: |
| 35 | +You can open the command line by pressing the `Windows key + s` in Windows, entering “cmd**” in the search field, **then right-clicking with the mouse pointer** on the “Command Prompt” selection and selecting “Run as administrator**.” |
| 36 | +#### Open Powershell: |
| 37 | +To open the Powershell console, use the key combination `Windows key + s`, enter “**powershell**,” and then right-click and select “Run **Powershell as administrator**.” |
| 38 | +## Overview of **netstat** functions |
| 39 | +You can get an overview of the functions and parameters of **netstat** by entering the following command in the console window: |
| 40 | + |
| 41 | +```msdos |
| 42 | +netstat help |
| 43 | +``` |
| 44 | + |
| 45 | +netstat help |
| 46 | + |
| 47 | +The overview now shows the available functions and parameters that can be combined with **netstat**. The parameters can also be combined with each other. |
| 48 | +### Display active connections |
| 49 | +After opening your console, you can display all active connections on your computer by entering the command |
| 50 | + |
| 51 | +```msdos |
| 52 | +netstat -a |
| 53 | +``` |
| 54 | +to display all active connections on your computer. |
| 55 | + |
| 56 | + |
| 57 | +netstat windows |
| 58 | + |
| 59 | +The table view is divided into four columns. |
| 60 | +#### Protocol |
| 61 | +The first column shows the protocol used for the connection. |
| 62 | +#### Local IP address |
| 63 | +The second column shows the locally used IP address and the port used, where the address 127.0.0.1 stands for local processes (on the same computer) that listen for internal connections and exclude external connections (Internet and other external networks). |
| 64 | + |
| 65 | +The `IP address 0.0.0.0` in conjunction with a displayed port listens for all requests from all network interfaces and accepts these connections. |
| 66 | +#### Remote IP address |
| 67 | +The third column shows the IP address and port used by the remote address. |
| 68 | +#### Status |
| 69 | +Finally, the fourth column shows the current status of this connection. This status is displayed in the states “LISTENING, WAITING, ESTABLISHED, and CLOSE\_WAITING.” |
| 70 | +### Display routing tables |
| 71 | +It is equally important to be able to track the routing of IP packets. |
| 72 | +The following command allows you to display the configured routing table. |
| 73 | + |
| 74 | +```msdos |
| 75 | +netstat -r |
| 76 | +``` |
| 77 | +This gives you an overview of which subnets IP packets can be routed to, for example, from the subnet used by your computer to other subnets (e.g., other subdomains, Internet gateway, etc.). |
| 78 | +### Display network interfaces |
| 79 | +Here you can display the individual network interfaces available on your Windows device and, for example, whether and which interface is active (status). |
| 80 | +To display the information described above, use this command. |
| 81 | + |
| 82 | +```msdos |
| 83 | +netstat -i |
| 84 | +``` |
| 85 | +## Overview: netstat commands in Windows |
| 86 | +</br> |
| 87 | + |
| 88 | +| Command |Description | |
| 89 | +|---------------------------|--------------------------------------------------------------------------------------------| |
| 90 | +| netstat | Displays all active TCP connections | |
| 91 | +| netstat -a | Displays all active TCP connections and the TCP/UDP ports on which the computer is listening | |
| 92 | +| netstat -n | Displays connections with numeric IP addresses and ports without name resolution | |
| 93 | +| netstat -o | Displays active TCP connections including process ID (PID) | |
| 94 | +| netstat -e | Displays Ethernet statistics such as bytes and packets sent/received | |
| 95 | +| netstat -s | Displays statistics per protocol (e.g., TCP, UDP, ICMP, IP) | |
| 96 | +| netstat -p <protocol> | Displays connections for the specified protocol (e.g., TCP, UDP, ICMP) | |
| 97 | +| netstat -r | Displays the routing table (similar to “route print”) | |
| 98 | +| netstat -b | Displays outgoing/incoming connections and associated programs/file paths | |
| 99 | +| netstat -f | Displays full domain names for foreign addresses | |
| 100 | +| netstat -x | Displays NetworkDirect connections (Windows-specific) | |
| 101 | +| netstat -q | Displays listening and non-listening ports | |
| 102 | +| netstat -t | Displays the offload status of current connections | |
| 103 | +| netstat -y | Displays connection template information | |
| 104 | +| netstat /? | Displays all available parameters and a help overview | |
| 105 | +| netstat [interval] | Repeats the display at the specified interval in seconds (e.g., netstat -n 5) | |
| 106 | +</br> |
| 107 | + |
| 108 | +> - **Many parameters** can be **combined**, e.g. `netstat -ano` shows all connections with PID and without name resolution. |
| 109 | +> |
| 110 | +> - Some options are specific to certain protocols or network environments; **for details, refer to the help page** (`netstat /?`). |
| 111 | +
|
0 commit comments