I built a new server to replace an existing staging server. After I did the cutover and made the new one my staging server, I realized I wasn’t able to ping internally on the network as well as outside. I checked the networking on the VMware server and it was set correctly but I still kept getting the following error on ping:
$ ping google.com
ping: unknown host google.com
I checked the hosts file under /etc/hosts and the hostname file and both of them were fine. However, I tried to ping the IP of google and I was able to connect. Which made me realize that resolving of the domain names to IP via DNS (Domain Name System) is not working.
Next, I did a nslookup for an internal system and google and didn’t get any response:
$ nslookup google.com
;; connection timed out; no servers could be reached
And then I tried doing a nslookup by using Google’s Name Server 188.8.131.52. A Name Server is a specialized server on the Internet that handles queries or questions from your local computer, about the location of a domain name’s various services.
A great simple way to think about name servers is using a phone book analogy. If you were trying to call Joe’s Trading Company, you’d want to look it up in a phone directory to find the phone number. The Name Server or DNS Server as it is also called does the same thing with finding out IP addresses for websites/DNS entries.
But anyways, here’s the output of nslookup when I used Google’s Name Server:
$ nslookup google.com 184.108.40.206
So, I came to a conclusion that the DNS resolution wasn’t working. I checked out the resolv.conf file on my local machine and realized it had been blanked out – possibly during the host/IP switchover. I checked another working server and copied over the configuration to my local file under /etc/resolv.conf. resolv.conf is the name of a computer file used in various operating systems to configure the system’s Domain Name System (DNS) resolver.
After saving the file, I did a nslookup and got the following result:
$ nslookup google.com
A little bit more about DNS requests and how they work
But just how exactly did your computer know what webpage to display for you, and what server to pull it from?
Your web-browser knows you typed google.com into the address bar.
Your current nameservers from the resolv.conf file are retrieved.
Your computer asks the nameservers for the A (address) record for google.com.
The nameservers respond back with the IP address 220.127.116.11.
Your computer sends a request to that IP address along with the page you're requesting.
The web server hosted on google.com then sends your web browser the requested page.
Note that on occasions, there might be canonical names (CNAME) assigned to a website. If you do a nslookup on the website, the nameserver will respond back stating that the requested entry is a canonical entry and then provide the address (A) record for the main server. e.g. Google uses WebEx’s services and have a unique URL for their operation. They may not have a standalone server but may be sharing the same WebEx’s server with other clients of WebEx. I did a nslookup on google.webex.com and the result confirmed that the dns was a canonical (CNAME) entry
$ nslookup google.webex.com
google.webex.com canonical name = nebulau.webex.com.
nebulau.webex.com canonical name = global-nebulau.webex.com.