Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Unix >> Linux >> Networking >> How to use netstat to list tcp ports listening and udp ports listening


## List only Listening TCP ports and the owning process

[root@rhel7server1 ~]# netstat -tlnp
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:111             0.0.0.0:*               LISTEN      692/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1903/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1268/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1266/cupsd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1544/master
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      2172/sshd: root@pts
tcp6       0      0 :::111                  :::*                    LISTEN      692/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      1268/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      1266/cupsd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1544/master
tcp6       0      0 ::1:6010                :::*                    LISTEN      2172/sshd: root@pts

## Limit to ipv4 only

[root@rhel7server1 ~]# netstat -tlnp4
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:111             0.0.0.0:*               LISTEN      692/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1903/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1268/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1266/cupsd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1544/master
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      2172/sshd: root@pts



## List only Listening UDP ports and the owning process

[root@rhel7server1 ~]# netstat -ulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:38263           0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:866             0.0.0.0:*                           692/rpcbind
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1000/dhclient
udp        0      0 0.0.0.0:111             0.0.0.0:*                           692/rpcbind
udp6       0      0 :::866                  :::*                                692/rpcbind
udp6       0      0 :::111                  :::*                                692/rpcbind


## Limit to ipv4 only

[root@rhel7server1 ~]# netstat -ulnp4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:38263           0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:866             0.0.0.0:*                           692/rpcbind
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:68              0.0.0.0:*                           2344/dhclient
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1000/dhclient
udp        0      0 0.0.0.0:111             0.0.0.0:*                           692/rpcbind


## List both TCP and UDP listening ports and the owning process

[root@rhel7server1 ~]# netstat -tulnp
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:111             0.0.0.0:*               LISTEN      692/rpcbind
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1903/dnsmasq
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1268/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1266/cupsd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1544/master
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      2172/sshd: root@pts
tcp6       0      0 :::111                  :::*                    LISTEN      692/rpcbind
tcp6       0      0 :::22                   :::*                    LISTEN      1268/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      1266/cupsd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1544/master
tcp6       0      0 ::1:6010                :::*                    LISTEN      2172/sshd: root@pts
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:38263           0.0.0.0:*                           719/avahi-daemon: r
udp        0      0 0.0.0.0:866             0.0.0.0:*                           692/rpcbind
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1903/dnsmasq
udp        0      0 0.0.0.0:68              0.0.0.0:*                           1000/dhclient
udp        0      0 0.0.0.0:111             0.0.0.0:*                           692/rpcbind
udp6       0      0 :::866                  :::*                                692/rpcbind
udp6       0      0 :::111                  :::*                                692/rpcbind


[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]