DEV Community

What's DNS?

Gabriel Guzman on April 25, 2018

DNS is basically the address book of the internet. When you type www.duckduckgo.com into your browser, the computer needs to figure out how to get...
Collapse
 
ggenya132 profile image
Eugene Vedensky

Hey this is kind of awesome thanks for writing this. Question about CNAME: is the CNAME yet another shortcut to the ip? In other words, if I type in the CNAME into the browser, what's the process of resolving to one of those IPs look like. Does is resemble something like this data structure?

{
      'duckduckgo.com': {
        'www.duckduckgo.com': [
          '23.21.193.169',
          '107.20.240.232',
          '184.72.104.138'
        ]
      }
    }
Collapse
 
gabeguz profile image
Gabriel Guzman

Hi Eugene, exactly. A CNAME is basically a shortcut or an alias to an A record. A CNAME can't point directly to an IP address, it always points to another name.

CNAME:  myhost.duckduckgo.com -> A: www.duckduckgo.com
CNAME:  duckduckgo.com -> A: www.duckduckgo.com 
A: www.duckduckgo.com -> IP: 23.21.193.169', '107.20.240.232', '184.72.104.138

So, you can have any number of CNAMEs that point to any of your A records (or names) but not directly to an IP. A records point a name to an IP.

Collapse
 
david_adam profile image
David Adam

Thanks a lot. Could you please explain the last line of the article "this won't always work because you can have multiple websites running on the same server at the same IP address". If you can please explain this I would be very grateful to you.

Collapse
 
gabeguz profile image
Gabriel Guzman

Sure, I can have multiple CNAMES pointing to the same IP address, for example:

mysite.com -> 192.168.1.30
othersite.com -> 192.168.1.30
thirdsite.org -> 192.168.1.30

When I type 192.168.1.30 into my browser, the server won't know which website I'm asking for, so it will return either the default website for that server, or an error.

Collapse
 
juliavii profile image
juliavii

Awesome explanation! This is the kind of article we need to read while learning network or dev. Thank you!

Collapse
 
gabeguz profile image
Gabriel Guzman

Glad you liked it!

Collapse
 
msosto profile image
Mariano

great explanation. Short, concise and very clear. Thanks !