8

If I execute ss -lu in order to view all the listening UDP sockets, then none of the sockets are displayed. If I execute ss -au, which lists all(both listening and non-listening) UDP sockets, then "listening" sockets are displayed as UNCONN (see below).

What is the logic behind this? For example running atftpd listening for connections, should have state LISTEN not UNCONN, shouldn't it?

T60:~ # lsof -n | sed -n '1p;/UDP/p'
  COMMAND    PID TID  USER    FD  TYPE  DEVICE SIZE/OFF  NODE NAME
avahi-dae    963     avahi   11u  IPv4    9088      0t0   UDP *:mdns
avahi-dae    963     avahi   12u  IPv4    9089      0t0   UDP *:44639
    cupsd   1238      root   10u  IPv4    8160      0t0   UDP *:ipp
   dhcpcd   2072      root    7u  IPv4  532052      0t0   UDP *:bootpc
dhclient6  13131      root    5u  IPv6   38031      0t0   UDP *:dhcpv6-client
dhclient6  13131      root   20u  IPv4   37954      0t0   UDP *:20152
dhclient6  13131      root   21u  IPv6   37955      0t0   UDP *:36745
   atftpd  20639      tftp    0u  IPv4  344977      0t0   UDP *:tftp

netstat

T60:~ # netstat -lu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
udp        0      0 *:bootpc                *:*                                 
udp        0      0 *:tftp                  *:*                                 
udp        0      0 *:44639                 *:*                                 
udp        0      0 *:ipp                   *:*                                 
udp        0      0 *:20152                 *:*                                 
udp        0      0 *:mdns                  *:*                                 
udp        0      0 *:36745                 *:*                                 
udp        0      0 *:dhcpv6-client         *:*                                 

ss

T60:~ # ss -lu
Recv-Q Send-Q   Local Address:Port  Peer Address:Port

T60:~ # ss -ua
State       Recv-Q Send-Q   Local Address:Port            Peer Address:Port
UNCONN      0      0                    *:bootpc                     *:*
UNCONN      0      0                    *:tftp                       *:*
UNCONN      0      0                    *:44639                      *:*
UNCONN      0      0                    *:ipp                        *:*
UNCONN      0      0                    *:20152                      *:*
UNCONN      0      0                    *:mdns                       *:*
UNCONN      0      0                   :::36745                     :::*
UNCONN      0      0                   :::dhcpv6-client             :::*


T60:~ # ss -v
ss utility, iproute2-ss110629
3
  • Maybe just wording? A listening socket is obviously unconnected... ;-) – Hauke Laging Apr 17 '13 at 11:05
  • 1
    @HaukeLaging Not to mention both sound bad considering UDP :) – TNW Apr 17 '13 at 11:30
  • I've noticed that the behavior of -ul varies between RHEL5 and RHEL6. It is meaningless to RHEL5, but RHEL6 does what you'd expect it to. (the state is still listed as UNCONN in the output, but it only shows the listeners) – Andrew B Oct 5 '14 at 2:50
5

UDP is a connectionless protocol. SS probably won't show one in LISTEN state, only in UCONN or ESTAB.

If I do this,

$ nc -u -l 2333

Then ss will show (in a 2nd shell):

$ ss -au|grep 2333
UNCONN     0      0                       *:2333                     *:*       

If I then connect to it (3rd shell)

$ nc -u localhost 2333

then SS shows:

$ ss -au|grep 2333
ESTAB      0      0               127.0.0.1:2333             127.0.0.1:58434   
ESTAB      0      0               127.0.0.1:58434            127.0.0.1:2333    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.