According to this page it appears to be simple. However, /etc/bind does not exist on the default installation of Ubuntu 12.04.3 LTS server.

So, without installing any further software, how can configure DNS and remove dnsmasq on ubuntu server? I am quite familiar with sudo & nano.

  • Also take a look at help.ubuntu.com/community/Dnsmasq. bind IS a nameserver. If you need nameserver functionality on your server, you must install a nameserver. It would help if you could describe what it is you are trying to achieve. – hmayag Sep 17 '13 at 21:37
  • 1
    You were reading a manual to configure a DNS Server, not how to configure the DNS entries in the server. The manual you should have read are this – Braiam Sep 17 '13 at 22:55
  • I don't have the rep to post a comment on another answer, but in reply to Nullet's answer on September 17th 2013, this worked for me. I was thinking that there was a problem with my router (a cheap, ISP provided one). I also think it worth mentioning that on the dns-nameservers line, you should use the IP of the public DNS. Don't use the local address of the DNS, which is most likely on your router. I was connecting to the DNS on my router, which for some unknown reason wasn't working with my server. Instead, I found out where the DNS on my router was getting its information from, and set dn – kyul Mar 11 '14 at 18:38
  • I think there is a better answer here unix.stackexchange.com/a/154538/82018 - basically you can override your dhcp settings to "prepend" a server in front of the ones you currently use. This is nice as you don't have to rely solely on the new server, you just give it precedence for lookups. – Steve Midgley Nov 22 '14 at 21:07
up vote 136 down vote accepted

Set DNS Servers:

You need to configure the /etc/network/interfaces file if you want to change your DNS server via the command line.

It should look something like this:

# The loopback network interface  
auto lo  
iface lo inet loopback  


# The primary network interface  
auto eth0 
iface eth0 inet static  
address 192.168.X.X
netmask 255.255.255.0
gateway 192.168.X.X
dns-nameservers X.X.X.X 

If you have more than one DNS server, just add a space between each:

dns-nameservers X.X.X.X Y.Y.Y.Y Z.Z.Z.Z

Just replace the Xs, Ys, and Zs with your own IPs of the DNS servers of choice, and when this is done, run this command to update the settings:

sudo ifdown eth0 && sudo ifup eth0

Hope this helps!

  • 1
    Yeah, dnsmasq is not installed on ubuntu server as default, if I remember correctly. – Nullet Sep 17 '13 at 22:47
  • 4
    tried @Nullet solution, but got this error, longtth@long-ubuntu-14:~$ sudo ifdown eth0 && sudo ifup eth0 interface eth0 not configured RTNETLINK answers: File exists Failed to bring up eth0. Can you help me fix it ? – Luke Mar 28 '15 at 13:58
  • 2
    Here's my situation: I opened the file indicated in this answer and I had only the first 3 lines in it. I pasted in the rest. I ran the command and I got this: ifdown: interface eth0 not configured RTNETLINK answers: File exists Failed to bring up eth0. That concludes the output I received. If anyone has any thoughts that come to mind feel free to respond. I would like to know: what, generally speaking, am I to replace the X's in address and gateway with? – GoProCameraByGoPro Mar 31 '15 at 10:36
  • 2
    @Mr.Hyde You shouldn't type these lines at terminal, you must to write them inside /etc/network/interfaces file. – Richard Aug 13 '15 at 3:19
  • 1
    Ensure that you are actually using eth0 and not something else like eth1. ifconfig. – briankip Mar 23 '16 at 10:47

protected by Community May 29 '15 at 8:07

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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