Set static ip if not obtained from DHCP (script)
dhclient should support fallback via lease declaration
have a look at the dhclient.conf
man page.
Add something like this to your dhclient.conf
timeout 10;
lease {
interface "eth0";
fixed-address 10.0.0.10;
option subnet-mask 255.255.255.0;
renew 2 2022/1/1 00:00:01;
rebind 2 2022/1/1 00:00:01;
expire 2 2022/1/1 0:00:01;
}
or you can assign a second IP to the interface like /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto eth0:1
iface eth0:1 inet static
address 10.10.10.2
netmask 255.255.255.0