Ignore DNS from DHCP server in Ubuntu

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x