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
    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. – Michael Kjörling Jun 14 '15 at 19:05
  • 2
    Because they needed to choose something? There isn't really any rhyme or reason behind port numbers. – David Jun 15 '15 at 0:02
  • why not........? :) – emirjonb Jun 24 '15 at 12:45
up vote 7 down vote accepted

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.

  • 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 at 18:19

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).

  • 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 '15 at 21:00

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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