Search code examples
linuxnameservers

how to add nameserver in resolv.conf


I researched about how to add a name server in the file resolv.conf, I found this command on this site:

namerslv -a -i ip address

I'm also confused with the example in that site, this one:

namerslv -a { -i IPAddress | -D DomainName| -S SearchList}

so which one I should use if I want to add just the name server?

-i
-D or
-S (I have doubts about this)

When I try to use it, it's not supported on my Linux.

Also, why is it important to list at least two name servers in the file resolv.conf?


Solution

  • vim /etc/resolv.conf

    Edit file - usually you would have:

    nameserver 8.8.8.8
    nameserver 8.8.4.4
    

    possibly:

    domain local.example.com
    

    or:

    search local.example.com
    

    This will help you with searches like:

    host hostname

    rather then

    host fqdn

    Adding more than one DNS entry is important from the redundancy point of view - if one fails you can still resolve names.