How to check which ports are open on Linux

Last updated on May 30, 2020 by Dan Nanni

Question: How can I check which TCP/UDP ports are currently open on my Linux system?

If a port is open, it means that there is an actively running program (e.g., daemon) which uses the port number to communicate with other programs locally or over the network. If you want to check which ports are open on local Linux system, you can use netstat command. The following will show a list of all active daemons. Under "Local Address" field, you can see the IP address and TCP/UDP ports that each daemon is listening on.

$ netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1539/dnsmasq    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1178/sshd       
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1285/cupsd      
tcp        0      0 0.0.0.0:902             0.0.0.0:*               LISTEN      1832/vmware-authdla
tcp6       0      0 :::22                   :::*                    LISTEN      1178/sshd       
tcp6       0      0 ::1:631                 :::*                    LISTEN      1285/cupsd      
udp        0      0 0.0.0.0:42874           0.0.0.0:*                           1635/dhclient   
udp        0      0 0.0.0.0:40610           0.0.0.0:*                           1223/avahi-daemon: 
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1539/dnsmasq    
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1539/dnsmasq    
udp        0      0 0.0.0.0:68              0.0.0.0:*                           3019/dhclient   
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1635/dhclient   
udp        0      0 0.0.0.0:17446           0.0.0.0:*                           3019/dhclient   
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           1223/avahi-daemon: 
udp6       0      0 :::22228                :::*                                3019/dhclient   
udp6       0      0 :::64460                :::*                                1635/dhclient   
udp6       0      0 :::49459                :::*                                1223/avahi-daemon: 
udp6       0      0 :::5353                 :::*                                1223/avahi-daemon: 

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean