dhcpcd-discuss

Re: Re: Persistent static IP, via CLI

Igor Pellegrini

Sat Dec 19 15:31:00 2020

Da: Roy Marples <roy@xxxxxxxxxxxx>
Inviato: venerdì 18 dicembre 2020 12:18
A: Igor Pellegrini <kairos_@xxxxxxx>; dhcpcd-discuss@xxxxxxxxxxxx <dhcpcd-discuss@xxxxxxxxxxxx>
Oggetto: Re: Persistent static IP, via CLI

> Hi Igor

Hi, thanks for the informative answer 🙂


> I really have no idea why people want to force DHCP to be a static never changing address. DHCP is not that and people should be aware that network addresses change.

I believe the purpose is "predictability" and to have machines with always reachable services.
In my case the idea is to propose a specific IP and "stick" to that same lease "as much as possible", w/o configuring the DHCP server (that is not accessible).
Ideally it'd' fallback to another lease if the preferred IP is not available (or we are in another network).
Still, I don't know anymore if that is anyhow possible with dhcpcd/dhcp.


> This is why we have DHCP servers that update DNS or mDNS locally.

Totally true. That's actually the source of my problem:
I see via `nslookup` that my router is storing multiple matches for the same PTR (all from previous DHCP leases) and I couldn't find a way to reset/flush that; there's no DNS management or SSH available available.
This lead my machines to keep looking for the wrong IP when resolving the hostnames; `ping` always gets some old IP record. It drove me nuts, because my Raspberry Pi is changing IP often, when restarted.

Otherwise yes, you are right, I would expect to rely on a solid DNS instead of trying to instruct the DHCP server.


> A static lease is not DHCP, don't do that.

Is the static lease outside the dhcp RFC?
I don't understand why it was implemented in dhcpcd, if the static assignment should be performed on the dhcp server.


> Use the INFORM option to do similar.

Should that update the server table with the informed IP?
I've tried `dhcpcd --inform $WIFI_IP/24 wlan0` but doesn't seem to be considered by the server.
Is it supposed to be effective just after setting a manual IP/MASK ?
I also tried to `dhcpcd --release $CURRENT_RANDOM_IP/24 wlan0` but doesn't help.
With `dhcpcd --request $WIFI_IP/24 wlan0` it keeps being offered a different IP.


>> 1. how do I set the static IP so that it uses the one in $WIFI_IP, being sure that it is persisted and not lost when doing the reboot of my system?

> Again, the dhcpcd requests the old IP if not expired.

So the important is to get offered the correct IP at the absolute first connection, otherwise the server will keep giving me the previous random IP for the next 8 days? (default lease time, iirc)
If I just had a way to reset the dhcp server I could test if DHCPREQUESTing a specific IP would be honoured; given that at the moment seems the server is ignoring either REQUEST and INFORM.


>> 2. how do I ensure that the configuration has been persisted?

> Use dhcpcd.conf to persist. Only way.

Oh. I misunderstand what `persistent` is meant do do then :(
Don't you think that the sentence at
  https://github.com/rsmarples/dhcpcd/blob/12cdb2be46e25e1ab99df18324b787ad8749dff7/src/dhcpcd.conf.5.in#L297-L298
and
  https://github.com/rsmarples/dhcpcd/blob/12cdb2be46e25e1ab99df18324b787ad8749dff7/src/dhcpcd.conf.5.in#L34-L37
might be misleading?

I read it like `persistent` make the configuration to not be lost at reboot.
And the second ref, that one can do everything via DHCPCD cli, without touching the dhcpcd.conf.


> Easy way, add this to /etc/dhcpcd.conf [..]
> Good luck!

Thanks! And thanks a bunch for all the tips, and for the your immense work of course :)

Archive administrator: postmaster@marples.name