Is it possible for the LAN port, to be a DHCP Client to its own DHCP server?

Hi,

In my quest to rid my network of all hardcoded IP addresses. I have come down to the final boss.

Can the router give itself its own DHCP address from it's own server ?

And without a static lease (dynamic dhcp lease based on MAC would be acceptable, as long as it doesn't specify an IP address)

No. This is not possible. And even if it was, it would be a bad idea because it would mean that it might get a random address.

3 Likes

When you say it's not possible, when you put the br-lan in dhcp client mode, is the dhcp server getting disabled ?
If not, is there something else that would prevent the dhcp server from responding to the client's request ?

1 Like

Yes, that is the first thing that will happen.

Another thing is that the DHCP server, in the default configuration, advertises its own local address for DHCP options 3 and 6 (gateway and DNS) which can't work if it doesn't know its own address.

Further, without setting your interface to static IP (with an address and subnet mask/size), the DHCP server wouldn't know what subnet and subnet size it is working with.

Finally, it would just be very bad thing if your router (the thing that arguably controls your network) doesn't have a deterministic address.

3 Likes

You can renumber network every second, just that you have to keep all configs handed out by dhcp for at least 2x dhcp ttl.

How are you going to reach the router when the DHCP server fails?

1 Like

I should emphasize that those two DHCP options are mandatory if you want a network that actually functions as users expect:

  • No DNS option: your computers will fail to resolve any and all domain names.
  • No gateway option: your computers will not be able to connect to the public Internet.

Let's not miss the forest for the trees here. Static addresses are still useful for network admins:

  • OpenWrt by default generates a static unique local address (ULA) prefix upon first boot. ULAs make internal IPv6 addressing practical, especially if you deploy a Wireguard tunnel.
  • If you want to use a DNS resolver that's not run by your ISP for good reasons, you will have to hard-code IP addresses for those DNS resolvers.
  • As @eduperez already mentioned, if the DHCP/DNS service on the router fails for any reason, a static address will allow you to SSH into the router to fix it.
1 Like