Ubuntu – Is there a way to refuse a dhcp response from a specific ip

networking

On my network I have two dhcp servers (not my fault).
Is there a way to refuse a dhcp response coming from a specific dhcp server?

Best Answer

  • According to the dhclient.conf manpage, it should be possible to do what you want by adding a reject directive to the /etc/dhcp/dhclient.conf file

       reject cidr-ip-address [, ... cidr-ip-address ] ;
    
       The reject statement causes the  DHCP  client  to  reject  offers  from
       servers  whose  server identifier matches any of the specified hosts or
       subnets.  This can be used to avoid being configured by rogue  or  mis‐
       configured  dhcp  servers, although it should be a last resort - better
       to track down the bad DHCP server and fix it.
       .
       .
       .   
       reject 192.168.0.0/16, 10.0.0.5;
    
    The above example would cause offers from any server identifier in the  entire
    RFC  1918  "Class  C"  network  192.168.0.0/16, or the specific single address
    10.0.0.5, to be rejected.
    

    Note the comment in the manpage though - better to track down the bad DHCP server and fix it.