resolv.conf is used by Linux servers for specifying DNS servers used to domain name resolution.
Location of the file is
/etc/resolv.conf
Example
root@maps:~# cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 root@maps:~#
In above example, google public name servers 8.8.8.8 will be used for DNS resolution.
If you edit this file, it get reset every time your reboot.
Editing resolv.conf on CentOS
On CentOS/RHEL, you can directly edit /etc/resolv.conf, it won’t get overwritten
vi /etc/resolv.conf
Editing resolv.conf on Ubuntu/Debian
If you need to set DNS resolver, you need to edit file
vi /etc/resolvconf/resolv.conf.d/base
Add
nameserver 8.8.8.8
One liner
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/base