I have a situation where I am able to launch CentOS 6.6 images on a subnet such that the VM instances get their IP addresses from the virtual gateway of the subnet. Now this gateway has gone wonky and I don't have the access to fix it, so I have set up my own DHCP server on this subnet.

So now there are 2 DHCP servers on this subnet and my VMs are getting random IP addresses, sometimes from one DHCP server and sometimes from the other. My question is that how I can configure the dhcp client on my VMs so that they make DHCP requests to only my DHCP server rather than the faulty one? man dhcp.conf has not been very helpful.


On CentOS 7 this can be achieved by creating the file /etc/dhcp/dhclient.conf and adding a line like


to reject DHCP offers from one server or the other (or in this example, from all DHCP servers on a specific subnet).

To filter DHCP offers only on a specific interface, place the reject directive inside an interface block:

interface "eth0" {

Note the interface name (here, eth0) must be placed in quotation marks, unlike the example shown in the man page for dhclient.conf.

In all cases, run systemctl restart network.service as the superuser for changes to take effect.

On CentOS 6.7 the same instructions work, however

  • Each interface uses a separate configuration file for dhclient. In the above example, the file to which the reject rule would be added would be /etc/dhcp/dhclient-eth0.conf (and there would clearly be no need to use an interface block).
  • The command to reinitialize the system's network interfaces is service network restart, which again must be invoked as the superuser.
  • Can I reject an IP address instead of a whole subnet? So for instance, will reject; work if is the IP address of the faulty DHCP server? – xkcd Dec 21 '15 at 9:54
  • Yes, you can specify an individual IP address like you show, as well as multiple IP addresses and ranges separated by commas. man dhclient.conf has more details and examples. – user123977 Dec 21 '15 at 10:27
  • I tried the reject IP_Address option in the dhclient.conf file but it still allocated the IP from the rejected DHCP server. Any ideas what is wrong? – xkcd Dec 21 '15 at 15:12
  • Not off the top of my head. Are there any clues in the system log? Note I've tested this only on CentOS 7. – user123977 Dec 21 '15 at 15:33
  • I am also using CentOS 7. Do you know which file has the relevant DHCP logs? – xkcd Dec 21 '15 at 18:54

DHCP works via a multicast request for an IP address. Which gets an IP address from the first DHCP server to respond. There is no way that I know of to force the client to get a DHCP address from a specific server.

In fact, running two DHCP servers that are not aware of each other is asking for the type of trouble you are running into. You need to get the faulty one shut down or fixed.

  • 1
    I cannot get the faulty one to be shutdown or fixed, its controlled by another team which are ... lets say busy. But there is an option in the dhclient command (-s), that lets you specify a specific dhcp server manually. Usually in Linux, if you have a command-line option, there is a reciprocal configuration file option as well. I just cannot find what to put in the dhcp.conf file to get the same result as running the dhclient -s command manually. – xkcd Jul 29 '15 at 11:34
  • 3
    DHCP works via a multicast request for an IP address - DHCP actually uses UDP broadcasts to the Layer 2 broadcast address It doesn't use multicast. – joeqwerty Dec 23 '15 at 15:39

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.