Q. I just got Linux installed on my system. I'm able to connect to internet via IP address only. I'm not able to find out information about setting up new DNS sever ip under Linux. How do I configure primary and secondary DNS via terminal / shell prompt?
A. Under Linux / UNIX / BSD operating system, you need to edit the /etc/resolv.conf file and add the line:
Login as the root, enter:
# vi /etc/resolv.conf
$ sudo vi /etc/resolv.conf
Modify or enter nameserver as follows:
Save and close the file. To test DNS configuration type any one of the following command:
$ host google.com
$ dig google.com
$ ping google.com
$ nslookup your-domain.com
google.com has address 18.104.22.168 google.com has address 22.214.171.124 google.com has address 126.96.36.199 google.com mail is handled by 10 smtp4.google.com. google.com mail is handled by 10 smtp1.google.com. google.com mail is handled by 10 smtp2.google.com. google.com mail is handled by 10 smtp3.google.com.
If you see valid output such as actual IP address or able to ping to remote server via hostname, it means that the dns is working for you. Also make sure you have valid default gateway setup, if you see the time out error.