Skip navigation.
Home

How to Prevent DHCP Client from Receiving IP from a Specific Server?

Sometimes, people may encounter multiple misconfigured DHCP servers in a LAN. Then you may keep receiving wrong IP/Gateway/DNS information that prevent you from connecting to the Internet.

Here's how to prevent your host from receiving DHCP information from the misconfigured server.

The following actions are tested under Oracle Enterprise Linux 5.

  • Get the name or ip of the misconfigured DHCP server:

    Check /var/lib/dhclient/dhclient-eth0.leases:

    lease {
      interface "eth0";
      fixed-address 10.182.121.208;
      option subnet-mask 255.255.254.0;
      option routers 10.182.120.1;
      option dhcp-lease-time 21600;
      option dhcp-message-type 5;
      option domain-name-servers 10.182.244.34,146.56.237.50,140.83.70.155;
      option dhcp-server-identifier 146.56.237.50;
      option broadcast-address 10.182.121.255;
      option domain-name "example.com";
      renew 2 2007/8/7 04:39:33;
      rebind 2 2007/8/7 07:34:09;
      expire 2 2007/8/7 08:19:09;
    }
    

    The IP is "146.56.237.50".

  • Create file /etc/dhclient.conf with contents:

    reject 146.56.237.50
    

    The reject statement causes the DHCP client to reject offers from servers who use the specified address as a server identifier. This can be used to avoid being configured by rogue or misconfigured dhcp servers, although it should be a last resort - better to track down the bad DHCP server and fix it.

  • Reobtain DHCP information by restarting the network interface:
    # ifdown eth0
    # ifup eth0
    

Reference

  • man dhclient.conf.

very useful tips

hope more can come.