Quick help: I’ve been hacked

The DNS service: What it is and how it works

GIGA4
We are Roberto and Francisco, a small team dedicated to web development and specialized in the technical side of the WordPress and WooCommerce platforms. We provide consulting and training, we develop plugins and themes, we optimize, we secure, we respond to security incidents and we maintain sites. Founded in 2012, we are the technical support behind more than a hundred web projects in Spain and Germany, and we are also an active part of the WordPress community.

šŸŒŽ It goes unnoticed—you don’t realize it, but you are constantly using the DNS service.

What is the DNS service?

🈯 You have probably always heard that the DNS service is a name translator. It translates the name assigned to a website (for example, google.es) into an IP (for example 192.0.2.1 or 2001:db8:85a3:8d3:1319:8a2e:370:7348), which is required to connect.

But I want to go a bit further and look at how this system actually works.
šŸŒŽ DNS works through a decentralized, hierarchical database that will always try to take you to your destination.

1ļøāƒ£ It all starts with the root servers.

These are servers maintained by different operators (mostly US organizations). Their job is to serve, maintain, and update the root zone file. It is a small text file of about 200 KB; you can see it here: internic.net/domain/root.zo…

This file is essential. It tells you who you need to ask for each type of domain (TLDs, the final part after the dot).

  • For .com domains, it points you to a.gtld-servers.net (and others).
  • For .es domains, it points you to a.nic.es (and others).

2ļøāƒ£ So now it is time to ask the specific server for that domain type.

For google.es, we would ask a.nic.es, but this server still does not give us the final answer; it tells us the next server we need to ask.

And here we need to draw a line that separates us. What has happened so far are “public” services funded by operators and domain purchases.


From this point on, the answer will be provided by our private DNS server.

3ļøāƒ£ Your server for that domain (private DNS).

In this case, the google.es domain has several of its servers configured as the DNS servers to query: ns1.google.com ns2.google.com ns3.google.com ns4.google.com

Why do several always appear? The system is redundant so it keeps working even if a server or connection fails.

So we ask, and it tells us that in this case, to reach google.es you need to go to the IP 142.250.185.3.

Done!

So, to obtain the IP of a domain we have queried:
1ļøāƒ£ Root servers: They give us the servers for that domain type.
2ļøāƒ£ Servers for that domain type: They give us the servers for that specific domain.
3ļøāƒ£ Servers for that domain: They give us the final answer.

This process would normally have fewer steps because both our computer and our internet provider cache at least part of this process, reducing the requests to 0, 1, or 2.

Beyond IP addresses

DNS does not only provide IPs; it has different record types for different purposes. A and AAAA records provide IPs, CNAME provides aliases, MX provides mail servers, and TXT includes text (usually used to declare information or for verification).

Characteristics of a DNS server

If you have a domain, it is important that your DNS server is reliable and redundant. Nowadays this is not difficult with most providers (many DNS servers are included with hosting), although there are still many providers that do not make it redundant.

But if you also have a website, ideally it should be fast, and if the site is aimed at a global audience, it is also worth having Anycast DNS (with servers distributed worldwide, so it responds faster in different regions).

Keep in mind that when someone visits your website, the first request made—and the first thing that takes time—is the DNS request.

For example, if that request takes 200 ms, you already start with that baseline delay, at least on the first load. On this website, DNS load time (blue) accounts for almost 1/4 of the site’s initial load time.

This tool allows us to see your domain’s DNS response time in different parts of the world.

This image is from a DNS service from a Spanish hosting provider that responds very well near its servers (4 ms in France, 20–30 ms in the rest of Europe) but poorly in the rest of the world (100–300 ms). Obviously, it does not have Anycast.
Image from a well-known provider with a dedicated DNS service using Anycast technology.
With a few exceptions, but in general it delivers good responses worldwide.

With this thread, I aimed to help you learn a bit more about DNS, see its technology, and understand where it stands right now. It is one of the most overlooked elements, but from time to time it is worth taking a look.

Bonus: Glue Records.

You may have noticed that the domain-type servers in step 2ļøāƒ£ give you a domain to reach the domain’s DNS servers in step 3ļøāƒ£. You would need to repeat the process again to obtain the IP of that domain, but could this not become an endless process?

Consider what happens if a domain’s DNS servers are within the same domain 🤯 We run into an edge case, because to obtain the IP you have to ask the DNS server, but it is that same DNS that gives you the IP of the DNS server. šŸ’„

For example, the DNS server for google.com is ns1.google.com. How do we first find out the IP of ns1.google.com without asking ns1.google.com, and then obtain the IP of google.com?

This is done with special records called “Glue Records”, which store the IPs of the domain’s DNS servers directly on the domain-type server in step 2ļøāƒ£.

For example, here the DNS server a.gtld-servers.net gives us the IP addresses of Google’s DNS servers directly.

Did you know these details about DNS? Do you know any other details or curiosities?

Leave a Reply

Your email address will not be published. Required fields are marked *