Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You can add a fixed "lease" definition to the DHCP client configuration, as discussed here: http://www.mail-archive.com/linux-il@cs.huji.ac.il/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 2015/1/12 00:00:01;
  rebind 2 2015/1/12 00:00:01;
  expire 2 2015/1/12 00:00:01;
} 

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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