Is there a way to cache the last IP assigned on DHCP clients and use that if the DHCP server is down?

Unix & Linux Asked by Eduardo Lucio on December 18, 2020

I would like my DHCP clients (CentOS 7) cache the last IP assigned (reserved) for them and use that if the DHCP server is down.

Below is the current network interface configuration of my DHCP clients:

vi ‘/etc/sysconfig/network-scripts/ifcfg-enp0s8’


vi ‘/etc/sysconfig/network’

# Created by anaconda


FURTHER QUESTION: If this is possible (or even a good practice) is this something that should be set on the DHCP server?
NOTE: I’m using ISC KEA DHCP (DHCPv4) as DHCP server.

3 Answers

Let me first try to make sure I understand your question: You seem to be asking for a feature that I'd call "client caching" of its last used IP address - See my comment to @RuiFRibeiro's answer. If that's correct, dhcpcd may have you covered through its "fallback" feature.

To quote the online documentation:

It is possible to configure a static profile within dhcpcd and fall back to it when DHCP lease fails. This is useful particularly for headless machines, where the static profile can be used as "recovery" profile to ensure that it is always possible to connect to the machine.

And wrt your NOTE: I do not know if this is something that should be set on the DHCP server - ISC KEA DHCP (DHCPv4), in my case.

No - the "Fallback" is not set on the server, it is set in the client's DHCP configuration file.

Hope that helps.

Correct answer by Seamus on December 18, 2020

When a system boots up with DHCP it can also request the last IP (a hint to the server to reissue). This was traditionally stored in dhclient.leases. I seem to lose track of where each distro hides it.

Answered by user442812 on December 18, 2020

You are inventing stuff.

The protocol does define nowadays that the client will try to request the last given IP from the DHCP server when booting. The last IP address is saved in the filesystem, and the DHCP daemon will first ask for it from the DHCP server, and only if refused will try to get a different one.

However, the client DHCP daemon won't try to give you the last IP address if there is no DHCP service present in the network. Imagine the problems it would cause detecting when you had a good or bad connection, or the possibility of duplicate IP addresses due to flaky cables.

Answered by Rui F Ribeiro on December 18, 2020

Add your own answers!

Related Questions

Cifs mounting subdirectories from linux

1  Asked on December 24, 2021 by s-olesen


System bootorder not found

1  Asked on December 24, 2021 by ronin-zeroo


Yocto recipe for systemd USER service

2  Asked on December 24, 2021 by nellorocca


source .pam_environment file

0  Asked on December 24, 2021 by subbeh


No such file or directory /etc/init.d/functions

6  Asked on December 22, 2021 by tecman


dd script with timings

1  Asked on December 22, 2021 by lmind


Qt: XKEYBOARD extension not present on the X Server

1  Asked on December 22, 2021 by pitosalas


Execute zsh alias when name contains a hyphen

2  Asked on December 22, 2021


Kali Error while installing any package

3  Asked on December 22, 2021 by parampreet-rai


Is there a awk command for searching if a user is logged on?

2  Asked on December 22, 2021 by darunia


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP