22

I'm reading a book on network programming with Go. One of the chapters deals with the /etc/services file. Something I noticed while exploring this file is that certain popular entries like HTTP and SSH, both of which use TCP at the transport layer, have a second entry for UDP. For example on Ubuntu 14.04:

ubuntu@vm1:~$ grep ssh /etc/services  
ssh             22/tcp         # SSH Remote Login Protocol 
ssh             22/udp

ubuntu@vm1:~$ grep http /etc/services  
http            80/tcp          www             # WorldWideWeb HTTP            
http            80/udp                          # HyperText Transfer Protocol

Anyone know why these have two entries? I don't believe SSH or HTTP ever use UDP (confirmed by this question for SSH).

2
  • 7
    22/udp was removed in Debian in 2016. IANA still lists 22/udp and lists both udp and tcp for most protocols that are only usually implemented on either one of them. Could just be that it means 22 is reserved for ssh in case somebody wants to implement ssh over udp some day? Commented Sep 25, 2019 at 20:58
  • 2
    See also section 7.1 of rfc6335 Commented Sep 25, 2019 at 21:03

1 Answer 1

29

Basically, it's because that was the tradition from way back when port numbers started being assigned through until approximately 2011. See, for example, §7.1 “Past Principles” of RFC 6335:

TCP and UDP ports were simultaneously assigned when either was requested

It's possible they will be un-allocated someday, of course, as ports 1023 and below are the "system ports", treated specially by most operating systems, and most of that range is currently assigned.

And, by the way, HTTP/3 runs over UDP. Though it can use any UDP port, not just 80/443. So really those are still unused.

As far as Debian is concerned, its /etc/services already had 22/udp in 1.0 (buzz 1996).

It was however removed in this commit in 2016, first released in version 5.4 of the netbase package.

As of writing, the latest stable version of Debian (buster) has 5.6. And the latest Ubuntu LTS (18.04, bionic) netbase package is based on Debian netbase 5.4 and you can see its changelog also mentions the removal of udp/22.

17
  • 4
    @SergiyKolodyazhnyy I'd think not, as this practice predates firewalls.
    – derobert
    Commented Sep 25, 2019 at 23:31
  • 3
    @TobySpeight That's not just Linux, that's part of the relevant standards. See, e.g., §6 of that RFC. Though the IANA also registers higher ports, they're a different classification (and that matters in practice because of how OSs, not just Linux, treat them). I'll clarify that a bit. Also, 0 isn't a valid port. It's used by the sockets API as a wildcard (to tell the kernel to pick a port for you).
    – derobert
    Commented Sep 26, 2019 at 7:38
  • 3
    "0 isn't a valid port" is questionable. It's certainly not a usable port on our OS (which is why I called it out specifically, and why it's currently reserved, and unlikely to be assigned to anything), but it's not special at the protocol level. Commented Sep 26, 2019 at 7:52
  • 1
    @derobert: Your argument is that port 0 is unusable on Unix machines because port 0 means "pick a free port". I'm saying that the argument is wrong. The conclusion does not follow logically from the premise.
    – MSalters
    Commented Sep 26, 2019 at 15:08
  • 3
    Though it can use any UDP port, not just 80/443 That's essentially true of any protocol TCP/UDP protocol, these are just the default ports associated with each. Most applications that use TCP and UDP don't provide a way to specify non-default ports, but HTTP allows them to be specified in URLs so it's more feasible to vary the port.
    – Barmar
    Commented Sep 26, 2019 at 21:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .