DNS 101

The Domain Name System (DNS) is a hierarchical and decentralized naming system for computers, services, or other resources connected to the Internet or a private network

Private DNS

$ cat /etc/hosts   www.backend.com   www.backend2.com
  • ping www.backend.com
  • ping www.backend2.com

You can use either names to read

Until the environment grew and the host files got filled with too many entries and managing these became too hard. If one of the servers’ IP changed, you would need to modify the entries in all of these hosts.

That is why we need to move all the entries into a single server who will manage essentially. we call that the DNS Server.

How do we point our host to a DNS Server?

$ cat /etc/resolv.conf
# macOS Notice
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
# To view the DNS configuration used by this system, use:
#   scutil --dns
#   dns-sd(1), scutil(8)
# This file is automatically generated.

Once this is configured on all of your host, every time a host comes up across a hostname that it does not know about, it looks it up from the DNS Server. If the IP of any of the host was to change, simply update the DNS Server and all host should resolve the new IP address going forward.

What if you have an entry in both places, one in your hosts file and another in DNS?

The host first looks in the local hosts file and then looks at the name server. So, if it finds the entry in the local hosts file, it uses. However, the order can be changed.

Record Types

How are the records stored in the DNS?

CNAMEapp.web-serverapps.web-server, apps1.web-server
Record Types
  • A: IPv4 IP
  • AAAA: IPv6
  • CNAME: Mapping one name to another name is called CNAME Record. Name to name mapping.


$ dig www.google.com

; <<>> DiG 9.10.6 <<>> www.google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54153
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;www.google.com.			IN	A

www.google.com.		92	IN	A

;; Query time: 3 msec
;; WHEN: Sun Jan 10 15:49:23 KST 2021
;; MSG SIZE  rcvd: 59

Leave a Reply

Your email address will not be published.