So, do I have to understand what DNS is, as a Web Developer? Let’s find out!
Let’s be honest as a Web Developer, we only hear about HTML, CSS, JavaScript, MYSQL, MongoDB, Git, etc. How about DNS configuration and deployment on a real web server? Before you say that DNS is not important, read the next wonderful paragraph.
Think of a burger 🍔 that does not have its own burger meat between the buns. It’s impossible to imagine it, correct? Well, it’s the same thing for DNS. Without DNS you cannot host your xyz.com website on a web server.
The deployment process is really easy and it comes in two steps. In the first step, via FTP, you can upload the files of your website. You can also choose to do it via SSH. However, if you have a shared hosting, due to security reasons, you most probably won’t have access to your server via SSH. Only if you have a VPS/ Dedicated Server. I won’t explain the first concept any further in this article. The second step consists of setting up the DNS configuration of your domain name.
To connect to the FTP Server you must connect to your FTP account via Filezilla, or another tool.
To connect via SSH, you must have a linux terminal, or Putty.
What is DNS?
Do you remember the yellow pages that were used in the past to find the phone number/ address of a person? Well DNS (Domain Name Service) is pretty much this. A user types in the browser the URL (web address) of the website he/ she would like to visit. After that, the DNS servers return the IP address of the Web server associated with the domain that you typed. For example, the domain xyz.com might be translated to 213.246.62.200.
DNS has multiple records that are used for different purposes.
The “A” record
This might be the most important DNS record. Basically, it says to the browser, point the website xyz.com to the address 213.246.62.200. To update, add, remove the A records of your domain name, you must have a DNS configuration panel. All Web Hosting companies are offering one, for example, Plesk / Cpanel, Directadmin etc.
To determine the IP of your website, you can use the Linux command > dig A xyz.com, inside a Linux terminal.
The “Cname” record
This DNS record maps an alias name to a canonical domain name. To have a better understanding, imagine the web address www.xyz.com, the CNAME record can map this web address to the actual website for the domain with the same name xyz.com.
“TXT” record
Usually, this record is used to verify the ownership of a domain. In some cases, you will be asked by the registrar of your domain to put a unique ID inside the TXT record.
The TXT record it’s also used for setting up the DKIM ( a technique that protects the email senders from spam, phishing etc).
Another use for TXT would be to set up the SPF, which is used to authorize which IP addresses can send email from one particular domain.
"MX" record
This record specifies the mail server responsible for accepting the incoming and outgoing emails on the behalf of the domain.
If you fell in love with DNS and you want to dig a little deeper, check out these commands.
ping xyz.com (to determine the IP of a web page, but is mainly used to determine the connectivity). Linux + Windows + Mac
dig xyz.com (this is the most popular command used to query the DNS zone of a domain). Linux + Mac
nslookup xyz.com (pretty much, same use as dig). Linux + Windows
Or to make it easier for you, use the online tool https://dnschecker.org/.
How DNS query works?
Now that we know a little about DNS, how does it really work?
Imagine, A user will type reddit.com on an internet browser, then your device will look into the local DNS cache of your machine. In the case where the device does not find an answer, it will go for a DNS query.
Your computer will contact your ISP’s recursive DNS servers, to request the IP of xyz.com. Recursive DNS servers have their local cache, much like your local computer. Some of the ISP’s are using the same recursive DNS servers. If the domain name is present in its cache, the query will end here, if not, will continue.
The DNS servers of the ISP, will then request the IP of reddit.com to the DNS Root Server. Then the Root Server sends back the IP of the .com top-level domain. Below you can see the steps of a DNS Query.
After, the ISP does request the IP of the authoritative server for reddit.com to the DNS Server for .COM domains. The server sends back the IP to the servers of the ISP’s Servers.
Another IP request of reddit.com from ISP is sent to the Authoritative DNS Server for reddit.com. The IP is sent back to the ISP and the ISP sends the IP back to the user and the website is displayed.
All this process takes only a few milliseconds.
DNS propagation time
Well, all sounds good, right? Not so fast! 💔
The DNS query is a really fast process, unlike the DNS propagation. 😭
The DNS propagation can take up to 72 hours, when you update the DNS zone. DNS when updated, it has to be replicated on the internet worldwide.
We are at the end of this article, therefore what’s the conclusion? Is DNS knowledge important for Web Developers? It’s not like a MUST HAVE, but it’s a nice extra knowledge to have. Especially if you are a Freelancer, working as WordPress / (other CMS) Developer. You might cash in some extra 💸 from your client, just because you have an extra skill that is really handy.
And OF COURSE, the most important thing of all. DNS JOKES.
“I’ll tell you a DNS joke but be advised, it could take up to 24 hours or more, for everyone to get it.” 😅🤓
My next article
Do not hesitate to come and say hi! 👋
My Twitter
Dribbble
Top comments (14)
Agree, you should know about DNS. That is a basic concept of the internet!
In my limited experience, regardless of your exact profession, people will view you as an expert on "the internet stuff", so I see it as my obligation, to understand basic concepts of "the internet stuff". --also, I don't trust people who are not curious enough to learn about underlying concepts :p
This includes:
I totally agree with you Lud!
Thanks for your comment! 😄
A nice top level overview. Well done. Just three minor things perhaps worth clarifying:
1) In your diagram, "Authoritative DNS Server" is often referred to as the "Nameserver". That is where the original A/CNAME/TXT records are stored when set by the user. The IP address of the nameservers is stored on the domain with the domain registrar. Request 4 asks for the nameserver IP from the domain registrar, request 5 returns the IP address to the nameserver, request 6 asks the nameserver for the A record for a specific domain, and request 7 returns that A record (a server IP address).
2) Step 8 does not actually return the webpage as indicated in the diagram. Now that the computer has the server IP, it needs to make a request to that server IP, hopping over the internet through various nodes known as the Border Gateway Protocol, which is an advanced topic outside the scope of this article. But in short, request 8 doesn't return the website.
3) You've mentioned if the ISP cache has the record, it stops there which is correct. Additionally, most computers/browsers have a DNS cache on the local machine, so often once a site is accessed, no further DNS requests for it are needed until that record expires (browser closes, DNS is cleared, or DNS record expires). Which means for sites you visit more than once, request 1 never needs to happen.
Wonderful post! No one ever mentions that DNS is the quintessential Frontend feature. Before your site is even seen users will depend on putting that url into the browser bar and expect to be taken to the site. Nothing would happen if your zone file is misconfigured.
Thx for a good read!
Thank you Judith!
I like your analogies 🙂 ... and the joke.
Hey Andrej,
Thanks a lot! 😄🤓
Thank's for this post it's really helpful.
Nice one! 😄
Hey,
Glad that you like it!
Thanks for the article, I often encourage my team to discuss about web beyond programming languages. All these days it was about SSL and PKI, will add DNS to the list and use your joke :)
Hey Niitn, thanks you for your reply.
Haha! Great! I am glad you like the article 😀
I did a DNS lookup for your joke but "The joke can’t be reached"😆
Some comments may only be visible to logged-in visitors. Sign in to view all comments.