2

I'm using 64-bit ArchLinux and dhcpcd. How to retrieve new IP using dhcpcd? I've tried to restart the daemon, the IP address i got still the same

$ ifconfig
enp3s0: flags ...
   inet xxx ...
$ sudo dhcpcd@enp3s0
$ ifconfig 
enp3s0: flags ...
   inet xxx ... ==> not changed

I've tried using sudo dhclient -v -r but the IP still the same.

I've found a way, but it still requires clicking on the system tray (disconnect, reconnect):

$ sudo rm /var/lib/dhcpcd/dhcpcd-enp3s0.lease
$ sudo systemctl restart dhcpcd@enp3s0
# right click on the network icon on system tray, disconnect, reconnect
2
  • 2
    You do know that it's possible for the DHCP server to always give the same IP address to a given hardware (MAC, ethernet) address, right? I have my home network's dhcpd configured to give a printer the same IP address every time. No amount of fiddling with dhcpcd will change that, you'd have to change the interface's MAC address.
    – user732
    Aug 14, 2015 at 16:31
  • 1
    I found this answered on server fault: "How do I force Linux to reacquire a new IP address from the DHCP server?" Oct 13, 2021 at 15:07

1 Answer 1

5

You've run ifconfig to see the interface name(s), that's a good start. After that, check if the ethernet cable is plugged in and working:

[root@splunge ~]# mii-tool enp3s8
enp3s8: negotiated 100baseTx-FD flow-control, link ok

That's from a working Arch server. You can use mii-tool or ethtool to check the connection and cable.

After you are certain the cable is plugged in and working, get rid of any dhcpcd still running or hung or something:

dhcpcd -k enp3s0

Then, run dhcpcd with debug messages turned on:

dhcpcd -d enp3s0

The messages from that invocation may help you decide what to do next.

Note that I'm assuming you will su - to log in as root, I find using sudo all the time cumbersome. If you want to sudo, modify the commands above appropriately.

EDIT:

I may have misunderstood your question. If dhcpcd is working, then it will always try to get the same IP address it had last time it got a lease.

You can force dhcpcd to get a completely different IP address by removing /var/lib/dhcpcd/dhcpcd-enp3s0.lease, and then stopping and starting the dhcpcd process.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .