14

I know that the DHCP is used to assign an IP address to the client and hence the only possible way to establish the connection is to listen on a specific port. But is there any specific reason behind choosing 67 and 68?

3
  • 7
    Likely the only people who can actually, theoretically answer this would be the people that designed BOOTP (RFC 951) in 1985 (or earlier). Everything else would be speculation. And while simply curiosity is sometimes a valid reason, I fail to see what problem this question aims to solve.
    – user
    Jun 14, 2015 at 19:05
  • 3
    Because they needed to choose something? There isn't really any rhyme or reason behind port numbers.
    – David
    Jun 15, 2015 at 0:02
  • why not........? :)
    – emirjonb
    Jun 24, 2015 at 12:45

3 Answers 3

16

DHCP is based on the earlier BOOTP protocol which uses well known port numbers for both server and client instead of an ephemeral port. The server and the client communicate via broadcast and the server broadcasts the offered IP address to the client on UDP port 68. The use of a well known port on the client's side is introduced to tackle the problem associated with this broadcast, which we will describe below.

Let's assume that host A is using the BOOTP client on ephemeral port 1883, and host B (which is on the same network) is using MQTT client on the same port. Now when the BOOTP server sends a broadcast reply message with the broadcast IP address 255.255.255.255 and destination port no. 1883, then host A will accept the correct message on its DHCP client on the application layer. But, the MQTT client which is running on the application layer of host B will get an incorrect message. The use of an well known port (in our case 68) prevents the use of the same two destination port numbers and hence it prohibits other protocols from using the same port which is already in use by another protocol. In simple words, it prevents an application from getting a message from a completely different protocol.

For more details I would recommend you to go through the RFC 2131.

1
  • 1
    In other words, the client-server distinction is not valid for UDP and when receiving "replies," the user's computer has to listen for them as if it was a server. But it's not just replies. Today's DHCP servers send push renewals which occur hours, sometimes days after the lease has been negotiated. This makes the listening on port 68 a true server-like job. BTW, the outgoing port is always 67, presumably so that userspace code couldn't spoof it.
    – Zdenek
    May 30, 2018 at 18:19
21

DHCP is based on BOOTP which was created in 1985.

BOOTP uses TFTP as the file transfer protocol.

TFTP was created in 1981 and uses port 69, so it was a thing of using the nearest non-used ports (68 and 67).

1
  • Thanks for the answer. I also researched a bit and came to the conclusion that the non-used port 68 is used at the client's side so that an application running on layer 5 does not get a message from another protocol.
    – valafar
    Jun 18, 2015 at 21:00
13

The answer is weirder than you think.

Have you ever wondered about the port numbers for early standard TCP services? 21 for FTP, 23 for TELNET, 25 for SMTP? Why are they all odd? How could ssh get 22 decades after telnet using 23?

Apparently the earliest iterations (before the seventies) of the TCP protocol was half-duplex, so bidirectional traffic needed two port numbers. Odd port numbers were reserved for the server side, even numbers were reserved for the client side.

BOOTP (the ancestor of DHCP) was conceived in the same era, and used the same concept: odd number for the serverside listening, even number for the clientside listening.

So how did SSH get 22? After decades of the de-facto standard of using odd numbers for server-side TCP services, it was still unusual to get an even numbered port for a service. However, by 1995, when ssh was first introduced, there was no longer any technical reason to not assign an even number, and noone was even afraid to anymore.

1
  • 1
    This is a great perspective.
    – KSK
    Apr 19, 2023 at 22:28

You must log in to answer this question.

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