Which utility can be used to view a list of open TCP connections on Linux on Windows system?

Netstat [network statistics] is a command line tool for monitoring network connections both incoming and outgoing as well as viewing routing tables, interface statistics, masquerade connections, multicast memberships etc. It can be used to list out all the network [socket] connections on a system. It lists out all the tcp, udp socket connections and the unix socket connections. Netstat is available on all Unix-like Operating Systems and also available on Windows OS as well. It is very useful in terms of network troubleshooting and performance measurement. netstat is one of the most basic network service debugging tools, telling you what ports are open and whether any programs are listening on ports.

List out all connections

The first and most simple command is to list out all the current connections. Simply run the netstat command with the a option.

# netstat -a

check the following snippet for the netstat output. Output contain multiple pages, so some data are omitted.

Explanation of each column

Proto – tell us if the socket listed is TCP or UDP. TCP connections are used for browsing the web and downloading files. UDP connections are used by certain fast-paced computer games and sometimes by live streams.

Recv-Q & Send-Q – tell us how much data is in the queue for that socket, waiting to be read [Recv-Q] or sent [Send-Q]. In short: if this is 0, everything’s ok, if there are non-zero values anywhere, there may be trouble.

Local Address & Foreign Address – tell to which hosts and ports the listed sockets are connected. The local end is always on the computer on which you’re running netstat and the foreign end is about the other computer

State – tells in which state the listed sockets are. The TCP protocol defines states, including “LISTEN” [wait for some external computer to contact us] and “ESTABLISHED” [ready for communication]. The stranger among these is the “CLOSE WAIT” state. This means that the foreign or remote machine has already closed the connection, but that the local program somehow hasn’t followed suit.

The above command shows all connections from different protocols like tcp, udp and unix sockets. However this is not quite useful. Administrators often want to pick out specific connections based on protocols or port numbers for example.

Don’t resolve host, port and user name in netstat output

When you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name. This also speeds up the output, as netstat is not performing any look-up.

# netstat -an

List only TCP or UDP connections

To list out only tcp connections use the t options.

# netstat -t

Similarly to list out only udp connections use the u option.

Listing all LISTENING Connections

# netstat -l

Listing all TCP Listening Ports

# netstat -lt

Listing all UDP Listening Ports

# netstat -lu

Displaying Service name with PID

# netstat -tp

Displaying Kernel IP routing

# netstat -r

Showing Network Interface Transactions

# netstat -i

Displaying RAW Network Statistics

# netstat –statistics –raw

You can only use netstat truly effectively if you know much about your network and your Linux system.

About the author

Mr. Suhesh KS is Linux System Administrator by profession with 10 Years of work experience in Linux system administration in web hosting, data center and data warehousing industry and have worked with reputed support companies. His wide range of skills include team management, system administration [ Linux ], programming [ bash, perl, php, java ,python], web hosting, data center support, cPanel Plugin development, website optimisation, Social media marketing.

Which utility can be used to view a list of open TCP connections on Linux or Windows systems?

The netstat utility displays incoming and outgoing network connections [TCP and UDP], host computer routing table information, and interface statistics.

Which utility can be used to view a list of open TCP connections on Linux or Windows systems ping ipconfig netstat tracert?

The netstat command will show a list of TCP connections, the IP address of your computer, the IP address of the device the connection goes to [the foreign IP address], the port numbers of both, and the TCP state.

How do I see TCP connections in Linux?

Check TCP Connection Status in Linux To display listeners and connections on Linux we can use the netstat or ss command. While older Linux boxes only support netstat, newer Linux distributions use netstat and ss in parallel.

How can I see open connections in Linux?

To get the list of all clients connected to HTTP [Port 80] or HTTPS [Port 443], you can use the ss command or netstat command, which will list all the connections [regardless of the state they are in] including UNIX sockets statistics.

Chủ Đề