2

I can configure RPi for DHCP client. But when the DHCP server is unreachable, I want to set specific IP. How can I configure dhclient for this?

2

There is a lease declaration. A quote from the manual:

The DHCP client may decide after some period of time (see PROTOCOL TIMING) that it is not going to succeed in contacting a server. At that time, it consults its own database of old leases and tests each one that has not yet timed out by pinging the listed router for that lease to see if that lease could work. It is possible to define one or more fixed leases in the client configuration file for networks where there is no DHCP or BOOTP service, so that the client can still automatically configure its address. This is done with the lease statement.

So, you could add into your dhclient.conf a declaration something like this

lease {
    interface "eth0";
    fixed-address 192.168.1.1;
    option subnet-mask 255.255.255.0;
    option routers 192.168.1.1;
    renew 2 2022/1/1 00:00:01;
    rebind 2 2022/1/1 00:00:01;
    expire 2 2022/1/1 0:00:01;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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