Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set DNS Server on Ubuntu?

Tags:

ubuntu

dns

I was wondering how to set a DNS server on Ubuntu to ever, with any network connection and any network device, use a predefined one.

So I "Duckduckgoed" a little bit and found some solutions.

I uncommented the following line in "/etc/dhcp/dhclient.conf":

prepend domain-name-servers x.x.x.x, y.y.y.y;

But, running Wireshark (after nm-tool and a reboot), I detected that my names still being solved by my default internet provider DNS server. =(

What I'm doing wrong? What am I supposed to do?

like image 279
Lino Avatar asked Mar 29 '15 14:03

Lino


1 Answers

If you want to OVERRIDE the DHCP server's provided DNS, you need to modify the file 'dhclient.conf'.

# sudo nano /etc/dhcp/dhclient.conf

then add a line for 'supersede' like following:

supersede domain-name-servers 8.8.8.8; # replace the IP with wanted DNS server

You will then need to restart your network on bash:

# sudo service networking restart
# sudo service network-manager restart

Now you can check it as following:

# nmcli dev show | grep DNS
like image 198
F.Tamy Avatar answered Oct 21 '22 09:10

F.Tamy