I set static DNS in /etc/resolvconf/resolv.conf.d/base file:

nameserver 8.8.8.8
nameserver 8.8.4.4

But my PC still obtains DNS from DHCP, this is my /etc/resolv.conf:

nameserver 192.168.100.2 
nameserver 8.8.8.8
nameserver 8.8.4.4

How to ignore obtained DNS from DHCP server?

up vote 22 down vote accepted

You can add this line to your /etc/dhcp/dhclient.conf:

supersede domain-name-servers 8.8.8.8, 8.8.4.4;

Then restart network or run dhclient to make changes.

From man dhclient.conf:

The supersede statement

       supersede [ option declaration ];

       If for some option the client should always  use  a  locally-configured
       value  or  values rather than whatever is supplied by the server, these
       values can be defined in the supersede statement.
  • 4
    Also you can comment out in /etc/dhcp/dhclient.conf in request parameters that you don't want to request, for DNS it can be domain-name, domain-name-servers, domain-search. – Alex Nov 8 '16 at 10:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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