Ubuntu Linux Configure DNS Name Server IP Address ( DNS Client )

Q. How do I change existing name server IP address? How do I configure DNS name server IP address under Ubuntu Linux / Debian Linux? How do I configure DNS name resolution under Ubuntu Linux?

A. You need to edit /etc/resolv.conf file under Debian / Ubuntu Linux to set Name server IP address that the resolver should query. Up to 3 name server internet IP address can be defined. If there are multiple servers, the resolver library queries them in the order listed.

Advertisement

Ubuntu Linux Configure DNS Name resolution

Type the following command, enter:
$ sudo vi /etc/resolv.conf
Or use nano text editor:
$ sudo nano /etc/resolv.conf
Append your ISP name server or free fast dns nameservers IP address as follows:
nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver 202.51.5.52

Save and close the file. Test your dns configuration by typing the following commands:
$ host yahoo.com
$ nslookup google.com
$ ping nixcraft.in

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

20 comments… add one
  • Ram Charan May 11, 2012 @ 11:39

    nameserver 208.67.222.222
    nameserver 208.67.220.220
    nameserver 202.51.5.52

  • Ram Charan May 11, 2012 @ 11:41

    nameserver 208.67.222.222
    nameserver 208.67.220.220
    nameserver 202.51.5.52

    how to set name server in ubuntu.
    pls help me………

  • Ivan Vatov Jun 27, 2012 @ 18:30

    sudo nano /etc/resolvconf/resolv.conf.d/base
    add your nameservers
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    nameserver 202.51.5.52
    and restart resolvconf
    sudo /etc/init.d/resolvconf restart
    this automatically update /etc/resolv.conf file
    thanks Noah Spurrier ;)

    • oserk Oct 2, 2012 @ 11:25

      Hi

      I’m on ubuntu 12.04. and I had to edit the head part of resolv deamon

      because the resolv.conf did had the first entry inside this:

      nameserver 127.0.0.1

      it never used the google nameservers that I defined in base or tail part… so what I did:

      sudo nano /etc/resolvconf/resolv.conf.d/head
      nameserver 8.8.8.8
      nameserver 4.4.4.4
      sudo /etc/init.d/resolvconf restart

      and content of resolv.conf file did have correct order:

      nameserver 8.8.8.8
      nameserver 4.4.4.4

      nameserver 127.0.0.1

      and I finaly did have fast new domain that I registered half hour ago ready to test!

      thanks to Ivan and others…

  • Jan Krojcer Aug 23, 2012 @ 11:21

    @Noah Spurrier: Thanks alot man, after a massive amount of research, I finally found your post. Every page that google turned up for “Setting a Static IP/DNS” involved editing the resolv.conf file… as if it didn’t get over-written. Editing the tail file works flawlessly, thanks a lot man.

  • Naveen Mar 4, 2013 @ 12:30

    This no longer applies on 12.10 because /etc/resolv.conf is a symlink to /run/resolv.conf/resolv.conf. /run is a tmpfs.

    $ ls -l /etc/resolv.conf
    lrwxrwxrwx 1 root root 29 Nov 21 22:49 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

  • shabnam Nov 2, 2013 @ 17:20

    Hi,
    how can i config DNS Server in ubuntu?
    plz help me.

  • Ayra Jan 13, 2014 @ 4:41

    Hello!
    I have a problem here..
    On our class, we configured and created our own DNS. my DNS is cogmaharlika.com.
    We changed our preferred DNS on our computer (Windows) to the IP Address of our server. I can access cogmaharlika.com but I cannot access google.com
    I can ping it inside my virtualbox but in the command prompt of Windows I cannot ping it. My classmates and I have done the same thing.. Theirs is working but mine is not.
    What is the problem?

  • Amit Jul 2, 2015 @ 11:58

    Hello!
    Hope you’re doing well.
    I have a problem with Static IP Addressing in redhat with terminal.
    Just want to know:
    Is it possible to make entry of dns without edit /etc/resolv.conf file?
    Or can we enter the dns with a command?

    Response will be appreciated !!
    Thanks,
    Amit

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.