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 188.8.131.52 google.com has address 184.108.40.206 google.com has address 220.127.116.11 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.Share this tutorial on: