We help IT Professionals succeed at work.

How to setup dns resolver in Ubunut 12 server ?

My first Precise Pangolin deployment.

I'm having issues with dns resolution not working - turns out /etc/resolv.conf is not anymore the place to manage this.

I tried to add “dns-nameservers”, “dns-search” and “dns-domain” entries in /etc/network/interfaces but they don't seem to work either (no server could be reached error, although I can ping those listed with dns-nameservers.

My interfaces files reads

auto eth0
iface eth0 inet static
dns-search mydomain.local

If I do a host xxx.domain.com it works - it's just that there is a config problem with default resolvers.

What am I missing ?
Watch Question

can you please post the contents of your /etc/resolv.conf file?

should be something like

search mydomain.local

Open in new window

can you also post the output of the command 'dig'?
should be something like:

; <<>> DiG 9.8.1-P1 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55303
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 0

;.                              IN      NS

.                       2816    IN      NS      f.root-servers.net.
.                       2816    IN      NS      j.root-servers.net.
.                       2816    IN      NS      m.root-servers.net.
.                       2816    IN      NS      e.root-servers.net.
.                       2816    IN      NS      h.root-servers.net.
.                       2816    IN      NS      a.root-servers.net.
.                       2816    IN      NS      c.root-servers.net.
.                       2816    IN      NS      l.root-servers.net.
.                       2816    IN      NS      d.root-servers.net.
.                       2816    IN      NS      g.root-servers.net.
.                       2816    IN      NS      b.root-servers.net.
.                       2816    IN      NS      k.root-servers.net.
.                       2816    IN      NS      i.root-servers.net.

;; Query time: 3 msec
;; WHEN: Thu Aug 16 12:19:16 2012
;; MSG SIZE  rcvd: 228

Open in new window


The  /etc/resolv.conf reads "#DO NOT EDIT THIS FILE" and has one entry "dns-search mydomain.local" (presumably carried over from the interfaces directives).

As for "dig" it times out with an error "no servers could be reached".
Wow - They changed the location of the resolvers on Ubuntu?
According to this file, you are right on the money on making changes to /etc/network/interfaces according to this link

Is your DNS server up?
Can you try putting on this file and see if DNS works first


Yes my DNS are working ok if I specify them in a "host" lookup. Just that somehow - despite my settings above - the system does not seem to know how to resolve by itself. Although a server it does not have BIND installed and don't really plan to.

As an aside what was the rationale behind removing support for /etc/resolv.conf ? I'm sure it's not just to annoy long time users... [Edited: ok I have followed some of the links above and better understand the change although not 100% convinced].
I managed to have it working by creating /etc/resolvconf/resolv.conf.d/tail file and manually inserting "nameserver x.x.x.x". This is being carried over into the "dynamically assembled" resolv.conf and allows for successful dns resolution. Obviously not the intended behavior but at least I can get things moving now...


Self solved

Explore More ContentExplore courses, solutions, and other research materials related to this topic.