$linuxcli.in _    [commands]    [tips & tricks]    [manpage]    [ESXi CLi]    [what is my ip?]    [pingme!]    [BIOS lock code]    [Code repo]


Command to prioritize DNS server address for DNS queries


Below command will keep your desire DNS server to be first address to use for a domain query resolver.

To apply this command root user privilege is require.

# sed -i '1i nameserver 8.8.8.8' /etc/resolv.conf

In the above example IP address 8.8.8.8 is a google public DNS IP address which can be use by anybody. The nameserver is an option in resolve.conf file to mention DNS server IP address which will resolve domain to IP address which was queried by application.

To change the nameserver IP address either you can be a root user to run this command as follow.

$ su -

# sed -i '1i nameserver 8.8.8.8' /etc/resolv.conf

Or you can use sudo tool if you are added in a sudoers list or in group that is already in sudoers list.

$ sudo sed -i '1i nameserver 8.8.8.8' /etc/resolv.conf

Last updated on 30 June 2023 10:43 am IST