Re: Persistent static IP, via CLI
Roy MarplesFri Dec 18 11:18:28 2020
On 17/12/2020 17:53, Igor Pellegrini wrote:
I'm pretty new to dhcpcd, we just met yesterday on a RaspberryPi, and I am trying to configure the network *without* relying on the `/etc/dhcpcd.conf`.
(I want to write some network configuration scripts, without messing with appending/removing instructions into the conf file).
The intention is to use DHCP on the interface, but always stick to the same IP, if this is available.
Ideally dhcpcd would be resilient to changing WiFi network and get an automatic lease when the IP is not available or we are in another subnet.
dhcpcd remembers the IP per Wifi network and requests it if not expired when it
If it's a new network or the lease has expired it just requests any address.
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. This is why we have DHCP servers that update DNS or mDNS locally.
Unfortunately I've got no luck and I am struggling with the little feedback that running commands returns.
Also I am not very confident with networking and linux configuration.
This is what I've tried:
sudo dhcpcd --release wlan0
sudo dhcpcd -S ip_address=$WIFI_IP/$SUBNET_MASK \
-S routers=$GATEWAY \
-S domain_name_servers=$DNS1,$DNS2 \
A static lease is not DHCP, don't do that.
Use the INFORM option to do similar.
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.
If it's expired, then it's expired and asks the server for any IP.
If the server is intelligent it will hand out the old IP if not re-used.
2. how do I ensure that the configuration has been persisted?
There are no changes in `/etc/dhcpcd.conf` after running the commands above.
I wonder if `--persistent` is actually intended to write that file; and if it should be called as separate command or if it can be added to any command (but I guess it works just with `--rebind` or few others?)
Use dhcpcd.conf to persist.
3. how do I ensure that the syntax of my commands is correct? And how do I ensure that they take effect? Even using `--debug` I do not receive relevant informations about the request or the response, except for
sending commands to master dhcpcd process
Easy way, add this to /etc/dhcpcd.conf
start ending commands
Look at the log file
Archive administrator: firstname.lastname@example.org