I have a piece of equipment I would like to default to a specific IP address when no dhcp servers are available.
I have set the following static lease in /etc/dhcp/dhclient.conf:
timeout 30;
lease {
interface "eth0";
fixed-address 192.168.1.254;
option subnet-mask 255.255.255.0;
option routers 127.0.0.1;
expire never;
}
It works, but eth0 will only get this IP when dhclient.eth0.leases and dhclient.leases in /var/lib/dhcp/ are empty.
Unless you guys have a good reason to advise against it, I would prefer if the static lease from dhclient.conf was assigned when a dhcp server doesn't reply instead of using old leases. It would make the troubleshooting process easier and allow some way to reach the equipment which is only accessible via ssh and has no display to print out the current ip.
I read through the dhclient manual and a lot of google search results but couldn't find a built in way or any suggestions on how to do this.
Solutions I thought of:
1-Empty dhclient.leases and set permissions so it can't be modified
2-Link dhclient.leases to /dev/null and set permissions so it can't be modified
3-Same as #1 but instead of setting up the static lease in dhclient.conf, manually add it to dhclient.leases before setting permissions.