Can a DHCP server assign itself an IP address via DHCP

Solution 1:

Technically the specs would allow for that to happen but it would be beyond stupid to try to do so.

Solution 2:

It's a bad idea in two ways but yes it is possible.

  1. The server can't assign an IP during boot-up when the DHCP server on the same machine hasn't been started yet. So you have to make sure that the DHCP server is up before trying to assign the IP.
  2. If the DHCP also updates the DNS for the dynamically assigned hosts then it is quite hard to know where your DHCP server is when the DNS fails (for whatever reason)

Solution 3:

In theory I think it SHOULD be possible since most linux distros these come up with an apipa (169.254.0.1 to 169.254.255.254) address if none is configured or provided. Therefore the dhcp server should be able to run and possibly answer requests. Now if you configure a reserved (fixed) ip address for the server's own mac-address, and if the dhcp client daemon stays running and keeps trying, it should in theory be able to be answered by the dhcp server daemon. Then it should be able to set its own proper ip-address, and continue to answer dhcp requests from other machines.

I'm not sure if dhcp servers can have an apipa address, an I think the server daemon needs to be restarted after the ip change, but other than that... I still cannot think of any sensible use case for this.

Tags:

Dhcp