0

I want to change the IP address persistently on a running rPi, by running a script. I tried now to change the /etc/dhcpcd.conf file and running

sudo systemctl restart networking

and

sudo systemctl restart dhdpcd

But ip a l still shows the old IP address (the new one is added though)

How can I change the address without needing to reboot? Of course I want to keep the new changes after a reboot.

1 Answer 1

1

Add the following at the end of your /etc/dhcpcd.conf file & re-start dhcpcd as you did before (or simply reboot):

interface wlan0
request 192.168.1.144/24
  • the first line (interface wlan0) indicates what follows is only for the wlan0 interface. If you want to apply this to eth0, then it would be interface eth0.

  • use the request option to ask the DHCP server for the specified IPv4 address (i.e. 192.168.1.144 is only an example). You should specify your address in CIDR notation, but it won't necessarily fail if you don't. Hint: If your subnet mask is 255.255.255.0, the CIDR designation is /24.

  • There are two caveats for the inform option:

    1. the IP address you request must be in the "pool" of dynamic addresses as defined in your DHCP server configuration.

    2. the IP address you request must be available; i.e. not assigned to another host. You can verify this by reviewing that active leases in your DHCP server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.