Default to Static IP when no DHCP is found

6,544

You can add a fixed "lease" definition to the DHCP client configuration, as discussed here: http://www.mail-archive.com/[email protected]/msg52652.html

The basic form is:

lease {
  interface "eth0";
  fixed-address 172.16.0.66;
  option subnet-mask 255.255.255.0;
  option routers 172.16.0.1;
  option domain-name-servers 80.58.0.33;
  renew 2 2022/1/12 00:00:01;
  rebind 2 2022/1/12 00:00:01;
  expire 2 2022/1/12 00:00:01;
} 

Add that to your dhclient.conf file and you should get the behaviour you want.

Share:
6,544

Related videos on Youtube

Max
Author by

Max

Updated on September 18, 2022

Comments

  • Max
    Max over 1 year

    I've setup a DHCP server on one of my centos boxes, and I have several computers that are going to connect (also centos) and hopefully make use of the DHCP. On start-up I'd like to check whether a DHCP server is available, or if the computer will have to fall back onto a static IP.

    My first idea is to modify the file under /etc/sysconfig/network via a script that would run on startup...is there an easier way to do this though? I would have hoped somewhere in the DHCP config there would be a way to specify a fallback point in the event no DHCP server is found. Thanks!