DEV Community

Cover image for How the Domain Name System (DNS) works - Basics
webdeasy.de
webdeasy.de

Posted on • Updated on • Originally published at webdeasy.de

How the Domain Name System (DNS) works - Basics

Originally published on webdeasy.de!

If I were to explain DNS to an 8-year-old, I would say: We are too stupid to remember numbers and DNS helps us to remember text instead.😋

DNS stands for Domain Name System and is one of the many systems that have been labelled as complicated. The concept is as simple as it is ingenious and without DNS the Internet as we know it would not exist!

Well, that’s a rather imprecise answer, but in principle this is a subtask of DNS, so we don’t have to remember the IP of a website, but a domain (81.169.255.51 becomes webdeasy.de).

Table Of Contents

How does DNS work?

To explain how DNS works, I have created a simplified diagram for you here.

On the left side we find your own PC, Smartphone or Laptop, i.e. your network device which is connected to a network. At home this is normally your home network with router and at school or university your network.

In the middle is a DNS server, this task is normally performed by the router you use to access the Internet. On the right side we have the server of the page you want to request.

The DNS works in a simplified way in the four steps shown. (diagram self made)

Let us assume you want to call up the page webdeasy.de via your web browser. We consider the “normal” configuration of a home network. In some networks, it can be that the structure is slightly different.

Step 1 – Ask DNS server for IP address

After you have sent the URL in your browser, this request goes to your router. It looks whether it finds an IP address to the entry for webdeasy.de in its DNS cache (register, in which the IP addresses with domain names stand).

If an entry exists, the system checks whether the TTL has expired. The simplest case is that this entry is still valid. Then your router returns the IP address and that’s it.

Step 2 – Router searches IP address on the Internet

If the entry does not exist or the TTL has expired, your router must search for the correct IP address. It does this by asking several DNS servers on the Internet for the current IP address. Until one DNS server answers and says: “Hey, I have the current IP for webdeasy.de“. With these basics we don’t care how the server works exactly.

Step 3 – Response with valid address is sent

The valid IP address is sent back to your router. It saves it again until it is needed again. Then the game would start again at step 1.

Step 4 – Response from Router to Client

After that you got the IP address of the target server and your computer would now request the actual data of the page via HTTP. The “DNS process” is now complete.

TTL

TTL stands for Time To Live and is a value that indicates in seconds how long a DNS entry is valid.

Normally the values for A entries are e.g. one hour (3600 seconds) and for NS entries one day (86400 seconds). However, this value may differ and can be adjusted in the DNS settings of a domain.

Especially if a page is to be moved to another server and the name server, mail server or website IP changes as a result, this value is often set to a few minutes in advance, as otherwise important services will be unavailable/faulty for many hours.

DNS Records

There are different DNS records or resource records, which all have different tasks. Since you can set up mail servers and the like for a domain, there are also different entries for different tasks.

I have arranged the order of the entries here in the table so that they are sorted by “importance” or “frequency”. Of course, this is not always the case, but can be a rough estimate.

Alt Text

How do I set DNS records and how can I check them?

You can set the entries directly with the provider from whom you have rented your domain. Most of the hosters I know offer these settings. Always with the hint that you should be careful. But you are now a DNS professional! 🙂

If you have rented your own server, you can also configure it as a name server. You can use e.g. Plesk for this.

There are many online tools on the Internet to check the DNS entries and also to view the current TTL. I prefer the tool from heise.de.

FAQ – Frequently asked questions

What is DNS simply explained?

In short, DNS is a form of information. Its main task is to resolve domains into IP addresses (name resolution). For example, it resolves the domain webdeasy.de into the IP 81.169.255.51. This is important for websites, but also for e-mails and many other applications.

What does TTL mean?

TTL stands for “Time To Live” and represents the validity period of a DNS record. The duration is specified in seconds. After the time has expired, the requested entry is invalid and will be queried again by the DNS server. In the meantime, the entries are in the server’s cache.

Why do new DNS entries or changes have a delay?

This is due to the TTL (Time To Live). The entries are stored in the server cache until the entry is declared invalid and is only then queried again by the requested server.

What is a DNS query?

Via a DNS query of a domain or IP you get the entry stored at the DNS server. For each DNS query you have to specify the desired DNS record.

What is the difference between DNS server and name server?

There is no difference. Both words refer to the same thing and mean the responsible server which has to take care of the name resolution.

What is the primary and secondary DNS server?

Multiple DNS servers can be set for network devices. If the primary server fails, the request is sent directly to the secondary one, so that no problems arise for the end user. The primary DNS server should always be the preferred server.

What are DNS settings?

DNS settings are often required for network devices. In a home network, the DNS server is usually the IP of your router. However, you should always specify a secondary DNS server.

On which layer in the ISO/OSI-7 model does DNS work?

DNS acts on layers 5 (security layer), 6 (presentation layer) and 7 (application layer). It is therefore not clearly assigned to a layer. Because of this unclear demarcation, layers 5, 6 and 7 are also combined into one in the TCP/IP model.

Conclusion

So DNS is a great relief for our everyday life and we all don’t want to miss it anymore, I think we all agree on that.

Thanks for reading! If you liked this article, please let me know and share it! If you want to you can check out my blog and follow me on twitter! 😊

Top comments (0)