Domain Name System (DNS) makes the Internet as we know it, work.
DNS is responsible for converting human readable Domain Names like www.newcars.com into computer readable IP addresses.
You can think of DNS as a distributed phone-book-directory which allows users to look up server locations by name instead of number.
When a user enters a Domain Name into a browser, their computers OS hands off the look up request to its configured nameserver resolvers.
Common records served by DNS
- A record
An A record takes a hostname like www or quote and relates it to an IP address:
www.newcars.com. 86400 IN A 184.108.40.206
- CNAME record
A CNAME record or alias is a name that refers to another name:
stage.newcars.com. 86400 IN CNAME www.newcars.com.
- PTR record
- A PTR record or reverse record takes an IP address and returns a name
Using dig to interact with DNS
- domain information groper is a network administration command-line tool for querying Domain Name System (DNS) name servers.
Use dig to lookup the IP address of www record from newcars.com domain
dig www.newcars.com +short 220.127.116.11
Use dig to lookup the IP address of stage record from newcars.com domain
dig stage.newcars.com +short www.newcars.com. 18.104.22.168
As you can see, stage.newcars.com is an alias to www.newcars.com. They are both pointing at the same IP address, and end up on the same server.
Now pretend we were given an IP address and we wanted to determine what name was related. The dash -x flag tells dig that we want to reverse lookup, IP to name.
dig -x 22.214.171.124 +short www.newcars.com.
- Note about +short
- The +short flag turns down the outputs verbosity.
- Why is DNS distributed?
- DNS is distributed to prevent outages. No one failure of a domain should take down the whole Internet. Authorative DNS servers maintain records for their hosts.