Using Netstat to Find Out What Ports are Open

The netstat command shows the services listening to ports on a Linux server and the details of any connections currently made to them. The connection details to consider during basic network daemon troubleshooting are the addresses that the daemon is listening on (including the port number), the daemon’s process identifier (PID), and the program name.

1
netstat -tulnp

Will yield an output similar to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3159/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:10000 0.0.0.0:* LISTEN 3253/perl
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3209/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3116/master
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::80 :::* LISTEN 2801/httpd
tcp6 0 0 :::22 :::* LISTEN 3209/sshd
tcp6 0 0 ::1:25 :::* LISTEN 3116/master
udp 0 0 0.0.0.0:960 0.0.0.0:* 2483/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 1/systemd
udp 0 0 0.0.0.0:10000 0.0.0.0:* 3253/perl
udp 0 0 127.0.0.1:323 0.0.0.0:* 2485/chronyd
udp6 0 0 :::960 :::* 2483/rpcbind
udp6 0 0 :::111 :::* 1/systemd
udp6 0 0 ::1:323 :::* 2485/chronyd

The netstat command line parameters are delineated as follows:

1
2
3
4
5
t – Show TCP
u – Show UDP
l – Show only listening processes (netstat can show both listening and all established connections, i.e. as a client too)
n – Do not resolve network IP address names or port numbers
p – Show the process name that is listening on the port
Lima

About the author

Lima is the visual nautical indicator for "stop instantly."

Comments

Leave a Reply