title
Stanislav Horváth
Standa HorvathFull Stack Developer
May 21, 2023 • 15 minLevel: Beginner
DNSDomainsLearning

What are domains for?

The Internet is composed of a multitude of computers, specifically servers (from the English word "serve"), which are interconnected. In order to identify each other, these machines must be numbered. Most people are aware that we are referring to IP addresses, which every such machine connected to the network has. An IP address can take one of two forms - the older IPv4 or the newer IPv6.

IPV4 vs IPV6

If you wanted to visit your favorite website, you would have to remember its server's IP address. However, that would be quite inconvenient, which is why domains were invented. A domain is a human-readable name composed of letters, hyphens, numbers, without diacritics and spaces. When we enter a domain into a browser, it first queries a DNS server responsible for translating domain names into IP addresses. The DNS server then returns the IP address we should connect to, the browser redirects us there, and we reach the desired page.

Domain Name Translation

Top-Level Domain (TLD)

Top-level domains (TLDs) are the highest level of a domain name, appearing after the last dot in a domain name. These domains are divided into several categories, such as .com for commercial websites, .org for non-profit organizations, and .gov for government websites. We also have newer and cooler top-level domains like .bank, .cloud, .club, and so on. The top-level domain often characterizes the geographical location of the application running on the domain. For example, if someone sends you a link to lidl.de, you will know that you will likely end up on the German version of the store.

Domains and Subdomains

Web domains are addresses used to identify websites on the Internet. These addresses consist of a domain name and a domain extension separated by a dot, such as example.com.

If we add another part before the domain name, we are referring to a third-level domain or subdomain, for example, like this:

Domain Structure

Interesting fact: It used to be (20+ years ago) that domains without www were not automatically redirected to www, as it is today. I'm sure you're familiar with it - you type seznam.cz in the address bar, for example, and the server automatically redirects you to www.seznam.cz. On the other hand, there are sites today that run directly on the main domain, without redirecting to www.

The reason for this slight chaos is just historical, previously the www subdomain was dedicated just for web pages and applications, while you would not find anything on the main domain in your browser. This practice has been partially preserved, which is why some sites run on the www subdomain and some do not, depending on the webserver settings.

Domain registrar

A domain registrar is a company that is responsible for registering and managing web domains. These companies provide domain name registration services and allow users to register their own domain.

Domain Registrars

DNS is a system that links a domain name to the IP address of the server on which the website is located. In this way, users can type the domain name into their browser and be redirected to the correct website.

Record types

A record

An A record is one of the most basic types of DNS records. It is used to translate a domain name (for example, www.example.com) to an appropriate IPv4 address (for example, 192.0.2.1). When a user enters a domain name into a web browser, the browser first contacts the DNS servers, which lookups the DNS records and returns the corresponding IP address. And the record contains just that information.

AAAA record

With the advent of IPv6 comes the need for a new type of DNS record that allows domain name to IPv6 address translation. The AAAA record (also known as a quad-A record) is used to map a domain name to an IPv6 address. While the A record works with IPv4 addresses, the AAAA record allows identification and communication with web servers that use the IPv6 protocol.

MX record

An MX record (Mail Exchanger) is a special type of DNS record that specifies where electronic mail should be routed for a given domain. When someone sends email to a specific domain (for example, example.com), the DNS server looks at the appropriate MX record, which contains information about the mail server(s) that should receive mail for that domain. The MX record allows mail to be routed correctly and delivered to the correct location.

TXT record

The TXT record (Text record) is used to add additional text information to a given domain. This information can have a variety of uses, such as domain authentication, setting up DomainKeys Identified Mail (DKIM), specifying a spam protection policy (SPF), or providing additional metadata about the domain. The TXT record provides flexibility and the ability to extend domain features using text data.

CNAME record

The CNAME (Canonical Name) record is used to create an alias for an existing domain. It is used to redirect one domain (alias) to another domain (target). This way you can create a link between two different domains.

For example, you would have an FTP server of your hosting in the format 1234.ftp.libovolny-hosting.com, but you would like to connect from your domain for example ftp.example.com. In this case, just add a CNAME which will point your subdomain "ftp" to your hosting's ftp server.

Record types in brief:

Record Types

Name Server

These are called Name servers, NS or DNS servers. This is a record that indicates where the DNS records for your domain are set up. It is therefore a pointer to where the inquirer (browser/server) should look when they want to know the legitimate value to your domain's DNS records. So it is technically possible to have a domain registered with one registrar, but realistically edit DNS records with another registrar or hosting company.

The why so complicated reasons may vary, the common denominator may be that you want to separate owning/maintaining a domain from managing it. For example, you own the domain example.com and you want to give the company/team the ability to manage the records, but you don't want to give them complete control over the entire domain. In this case, you just redirect the name servers to another registrar or hosting company and you're done. Name servers can be redundant, which helps their resilience - in other words you can set up multiple of them and when one goes down another takes over, reducing the chance of a broken domain.

Name servers

I would like you to take away from this paragraph that it is important to watch where my name servers are pointing. If you register a domain fresh, it will automatically be set to the registrar where you registered it, so you usually don't have to worry about anything.

How to set up a domain for your hosting

When setting up your domain, it will probably depend on whether you have purchased a domain including hosting for your site, as in this case the domain is quite often already pre-set and no major intervention is needed. For this tutorial, we'll assume that you don't have the domain preconfigured.

A, AAAA records

The first step is to find out where your domain should go, i.e. we need to find out the IP address of your hosting. You can find out the IP address by logging into your account, your hosting provider, and you can probably find it in the service details. For example, it might look like this:

Once we've found the IP address of the hosting server where our service is running, we can start adding a DNS record. To do this, we'll need to log into the account where we have the domain registered and get into managing DNS records for that particular domain.

Depending on the format of the IP address, we will choose to add a new DNS record. For IPv4 we choose DNS record type A and for IPv6 we choose DNS record type AAAA. There will likely be a total of 3 fields in the record entry form - name, value (IP address) and TTL (time to live). Let's break them down one by one.

Name - the name of the subdomain you want to point to. If we enter an alias, we are pointing to the main domain. If we enter an asterisk then we are pointing everything and if we enter a name then we are pointing the subdomain, we will explain it better with examples:

  • *.tonakodi.cz - it directs www.tonakodi.cz, tonakodi.cz but also for example abcd.tonakodi.cz, so it directs everything including the main domain
  • @.tonakodi.cz - it only directs the main domain tonakodi.cz
  • standa.tonakodi.cz - only the subdomain standa is directed

Value/IP address - this is the IP address where you want the domain to go, here you enter the IP address of the server where your service is running.

TTL - time to live, or how long the servers on the network should keep your DNS record in memory (in seconds) so that the routing is efficient. This is also the amount of time that your DNS records don't show changes after modifications because they are still held in cache by server points on the Internet. A common value is 3600, i.e. one hour.

A large number of records can be added to make the subdomain structure and routing that is needed. The more specific record always wins, meaning that if we have an asterisk * and a specific subdomain, the result will be that the subdomain will redirect according to its value and everything else will go where the asterisk points.

For example, the basic domain settings are usually as follows:

NameValueTTL
@89.221.218.383600
www89.221.218.383600

The setting directs the domain and subdomain www to the IP address 89.221.218.38.

MX record type

Now that we know how to create new A/AAAA records, this type will be a piece of cake. An MX record normally consists of the following values:

  • Host/Name - this is the subdomain that should carry the record, normally the @ suffix is filled in or left blank (the value will be carried by the main domain)
  • Value/Data - this is the address of your provider's mail server
  • Priority - The number by which the weight of the record is taken. This allows you to have multiple alternate mailservers and use the priority to determine which takes precedence.

You should get the values to insert into the DNS record from your hosting/mailserver provider either in the service details or on their website/knowledge base.

TXT record

You will probably need to set up TXT records if you want to add a DKIM for your mail server, or if you want to verify a web domain on Facebook. In such cases, knowing TXT records will come in handy. This consists of the following parts:

  • Host/Name - this is the subdomain that is to carry the record, normally left blank or filled with the record identifier
  • Value/Data - this is the specific data of the TXT record
  • TTL - time to live, see A/AAAA records, time in seconds how long the record should be cached by server nodes on the internet

You get the values for the TXT record from the service that requests it. For example, when you want to verify your domain for Google Search console, google will generate a code in the format

google-site-verification=<hash>

Which you insert into the data part, leave the Host empty and set the TTL to the base value of 3600.

CNAME type record

CNAME records have the same fields to fill as TXT records, they are:

  • Host/Name - this is the subdomain you want to target
  • Value/Data - this is the specific data of the CNAME record, i.e. where it should be directed to
  • TTL - time to live, see A/AAAA records, time in seconds how long the record should be cached by server nodes on the internet

What to watch out for

Although setting up domains can seem complicated, I think anyone can really do the basics. We are fortunate that the vast majority of registrars also have their own knowledge base, where you can usually learn all the essentials with a pictorial procedure.

There are a few things to focus on and double check before declaring a domain setup:

  • Check that your name servers/DNS servers are indeed pointing to where you have your DNS records stored. If you had your DNS servers incorrectly populated you could find that the changes would not show up at all
  • Check that you are properly redirecting the www subdomain for A/AAAA records. If you have filled in the alias or left the "Host/Name" field blank and you want your site to run on the www subdomain then you need to add another record for the www subdomain.
  • TTL shouldn't be too low, but also not too high (you would then wait a long time for possible promotion of changes), ideal value is from 3600 (hour) to 86400 (24 hours) depending on the ratio of the speed of promotion of changes and the load on DNS servers

I recommend to check the changes after the TTL expires after setting up the domain. You can use online tools to check. Alternatively, you can check the A records using the ping command on your computer

ping standa.tonakodi.cz

Where do you get the IP address you have set up in the domain

Pinging standa.tonakodi.cz [89.221.218.38] with 32 bytes of data:
Reply from 89.221.218.38: bytes=32 time=14ms TTL=54
Reply from 89.221.218.38: bytes=32 time=13ms TTL=54
Reply from 89.221.218.38: bytes=32 time=14ms TTL=54
Reply from 89.221.218.38: bytes=32 time=14ms TTL=54

If you've made it this far, thank you for reading this article and I wish you the best of luck setting up your domain. If you have any questions, please don't hesitate to contact me.


<SH/>Standa Horváth Copyright © 2001-2025 Fyzická osoba zapsaná v Živnostenském rejstříku od 6. 3. 2015,
evidovaná magistrátem města Liberce. IČO: 03866068