Why does DHCP have fixed client and server port numbers

In most client-server-applications, the port number of a server is a well-known number, while the client uses a currently available port number. DHCP is different. Here, both the client and the server use a well-known port: UDP port 67 for the DHCP server, and UDP port 68 for the DHCP client.

Why did they design it like that and have a fixed client port number?


Solution 1:

This is necessary as the client may not have an IP address when using DHCP (he uses DHCP to get an address).

The server and the client communicate via broadcasts so the server broadcasts the IP address of the client to UDP port 68. There is no other way for the server to reach the client. And this is the only way for the client to receive an answer to his request as he has no IP address.

Solution 2:

If I am assigning a temporary port number, say 10000, to a DHCP client then I have to assign the same port number to all the client in the network.

The DHCP server does not know the clients IP address, what it knows is the port number of DHCP client. So the DHCP server broadcasts the packet with the clients port number equal to 10000. If all the DHCP client are not assigned port number 10000 for DHCP application, it may be possible that some clients are running another application on port number 10000. The packet from the DHCP server will be delivered to wrong client-application. Hence it is better to use well known-port numbers for DHCP.