
Netstat: 7 Essential Commands to Spot Suspicious Connections Fast
Every computer that connects to a network leaves a trail. Some connections are ordinary, such as a browser fetching a web page or a mail client checking for new messages. Others are less welcome: a program quietly contacting an unfamiliar server, a port listening for traffic it should never receive, or a session that stays open long after work has ended. The netstat command gives you a fast, readable view of that activity, without installing extra software on most systems.
Netstat, short for network statistics, lists active connections, listening ports, routing information, and interface statistics. It is a diagnostic tool first, but it is also a practical security tool. When you know what normal looks like on your machine, unusual entries stand out quickly. That is why support engineers, system administrators, and security analysts still reach for it, even though newer tools exist.
What Netstat Shows You
At its simplest, netstat answers four questions. Which ports are open on this computer. Which remote addresses is it talking to. Which programs own those connections. And how much traffic has passed through each network interface. The answers help you check a service, test a firewall rule, or investigate a warning from antivirus software.
On Windows, netstat is built in and runs from Command Prompt or PowerShell. On Linux and macOS, it is often available, although many distributions now favour the ss command as a faster replacement. The ideas are the same either way: protocols, addresses, ports, states, and process owners. Learning netstat therefore makes other network tools easier to understand as well.
How to Read Netstat Output
A typical line contains a protocol, a local address, a foreign address, and a state. The protocol is usually TCP or UDP. The local address is your computer and the port it is using. The foreign address is the other end of the connection. The state describes where the connection is in its life cycle.
LISTENING means a program is waiting for incoming traffic on that port. ESTABLISHED means a live connection is in progress. TIME_WAIT and CLOSE_WAIT are normal stages while a connection closes, although many connections stuck in CLOSE_WAIT can signal a faulty program. For UDP, there is no connection state in the same sense, so entries simply show the local port that is open.
Ports also tell a story. Port 80 and 443 are normally web traffic. Port 53 is DNS. Port 22 is SSH. Port 3389 is Remote Desktop. A listening port you do not recognise is worth checking, but it is not proof of a problem by itself. Legitimate software, including cloud sync tools, update services, and remote support tools, opens ports too. The goal is to identify the owner before deciding what to do.
Common Netstat Commands That Cover Most Checks
Start with a broad view, then narrow it down. On Windows, netstat -ano is the most useful first command. It shows all connections and listening ports, uses numbers instead of names, and adds the process ID for each entry. From there, you can open Task Manager, match the process ID, and see which program is responsible.
On Linux, netstat -tuln is a good equivalent. It shows TCP and UDP listening sockets in numeric form. Add -p when you have permission, for example with sudo netstat -tulnp, to see the program name. For a live, frequently updated view, add an interval, such as netstat -an 5 on Windows, which refreshes every five seconds.
When you only care about one service, filter the output. On Windows, use findstr, for example netstat -ano | findstr :443. On Linux, use grep, for example netstat -an | grep 443. Filtering reduces noise and helps you focus on the port, address, or state that matters.
Netstat Flags Cheat Sheet
The table below summarises the flags you will use most often. The Windows and Linux versions overlap, but a few options differ, so check the version on your system before combining flags.
| Flag | What it does | Example |
|---|---|---|
| -a | Shows all connections and listening ports | netstat -a |
| -n | Shows addresses and ports as numbers, which is faster | netstat -an |
| -o | Shows the owning process ID on Windows | netstat -ano |
| -t | Shows TCP connections on Linux | netstat -t |
| -u | Shows UDP connections on Linux | netstat -u |
| -l | Shows listening sockets only | netstat -l |
| -p | Shows the program or protocol on Linux | netstat -tulnp |
| -r | Shows the routing table | netstat -r |
| -e | Shows Ethernet statistics on Windows | netstat -e |
| -s | Shows statistics by protocol | netstat -s |
A practical combination for a first security check is netstat -ano on Windows or sudo netstat -tulnp on Linux. A practical combination for troubleshooting a single service is the same command filtered to that service port. Keep the output, note the time, and compare it later if the problem returns.
Worked Example: Tracing a Suspicious Connection
Suppose you notice your laptop sending data while no browser or download is open. You run netstat -ano and see an ESTABLISHED TCP connection to an unfamiliar foreign address on port 4444, a port rarely used by everyday software. That single line does not prove malware, but it is enough to investigate methodically.
First, note the local port, the foreign address, and the process ID. Second, find the program behind that process ID. On Windows, open Task Manager, go to Details, and match the ID. On Linux, use ps or the -p output from netstat. Third, ask whether you recognise the program and whether it should be online. A backup tool, a game launcher, or a remote access tool may explain it. An unknown executable in a temporary folder is far more concerning.
Fourth, check the destination. A reverse lookup or a reputable IP reputation check can show whether the address belongs to a known cloud provider, a content delivery network, or a blocklisted host. Do not visit a suspicious address in a browser or download anything from it. Fifth, decide on containment. Close the program if it is safe to do so, disconnect from the network if the activity looks malicious, and run a full security scan. Finally, preserve evidence: save the netstat output, the process name, and the time. If the device is a work computer, report it to your IT or security team rather than deleting files or reinstalling first.
This is where netstat pairs well with deeper inspection. Netstat shows the connection, while packet capture can show what data, if anything, is actually moving. Similarly, understanding the tunnel or VPN in use matters, so it helps to know how IPsec VPNs work when a connection appears inside an encrypted tunnel rather than as a direct connection to a public address.
Using Netstat for Everyday Security Checks
Make netstat part of a short routine after installing new software, connecting to a new network, or responding to a security alert. Check for listening ports you did not expect. Check for established connections to countries or providers you do not normally use. Check for programs that connect at startup even when you have not opened them.
On shared or cloud servers, the same routine is more important. A server should expose only the ports its role requires. A web server needs 80 and 443, plus an administrative port that is tightly restricted. It does not normally need dozens of listening ports. If you find one, find out which service opened it, whether it is patched, and whether a firewall should block it.
Netstat also helps with false alarms. A security product may flag a connection that turns out to be a software update, a time synchronisation service, or a legitimate cloud backup. By identifying the process and destination, you can close the investigation with evidence instead of guessing. Record the normal baseline for each important machine so future checks take minutes rather than hours.
Netstat Limitations to Keep in Mind
Netstat shows current network activity, not history. A short-lived connection may already be gone by the time you run it. It also does not inspect packet contents, so it cannot tell you whether traffic is encrypted, benign, or stolen data. On modern Linux systems, netstat may be deprecated, and ss may be faster and more detailed. Finally, malware can hide processes or use legitimate programs to blend in, so a clean netstat result is reassuring but not conclusive. Use it alongside antivirus software, firewall logs, and endpoint monitoring.
Frequently Asked Questions
What is netstat used for?
Netstat is used to list active network connections, listening ports, routing information, and interface statistics on a computer.
Is netstat still available on Windows and Linux?
Yes, it is built into Windows and remains available on many Linux systems, although Linux users often use ss as a modern alternative.
What does netstat -ano do?
On Windows, netstat -ano shows all connections and listening ports in numeric form, together with the process ID that owns each entry.
How can netstat help find suspicious activity?
It can reveal unknown listening ports, unfamiliar foreign addresses, and programs connecting without a clear reason, which you can then investigate.
Does a strange netstat entry mean a computer is infected?
No, not by itself. Many legitimate programs open ports and connect to cloud servers, so always identify the program and destination before acting.
Netstat will not solve every network problem, but it gives you a clear starting point. Learn the main flags, build a baseline for your devices, and investigate unfamiliar entries calmly and methodically. That habit turns a simple command-line tool into an early warning system for suspicious connections.


