---
title: DNS Zone
description: Understand how DNS works, how to read and edit a DNS zone, and how to configure domain names for your self-hosted services.
---


:ellipsis{left=0px width=40rem top=10rem blur=140px zIndex=60}
# Domain Names and DNS Zones

::note
🎯  __Objectives:__

- Understand how a DNS server works
- Learn how to edit a DNS zone
::

## Introduction
---
When you browse a website or use an app, requests are made to one or more domains to fetch content for the page. Your device doesn't know the IP addresses of these servers, so it contacts a _name server_ (Domain Name Server), which responds with the most up-to-date IP address for the domain being requested.

The DNS zone is like a registry with signposts that direct your requests to the correct destination.

![Picture](/img/global/dns.svg)

## The DNS Zone
---
When you purchase a domain from a registrar (Cloudflare, OVH, etc.), the registrar assigns you a DNS zone that you can customize.

You can enter _records_ into this DNS zone to direct requests properly. You can find [more information here](https://help.ovhcloud.com/csm/fr-dns-servers-general-information?id=kb_article_view&sysparm_article=KB0051661).

Example of a DNS zone for the domain `mydomain.com`:

```
@ IN SOA ns1.dns.me. dns.net. (2024051800 86400 3600 3600000 60)
                 IN NS     ns1.dns.me.
                 IN NS     ns2.dns.me.
                 IN A      203.0.113.0
www              IN CNAME  mydomain.com
sousdomaine      IN CNAME  mydomain.com
```

In this example:

- `$TTL 3600` tells global name servers that the records are valid for 1 hour (after which they need to re-check).
- `IN SOA ns1.dns.me. dns.net. (...)` indicates `ns1.dns.me` as the primary DNS server, with refresh intervals.
- `IN NS` records define the authoritative name servers for the domain.
- `IN A 203.0.113.0` means `mydomain.com` points to IP `203.0.113.0`.
- `subdomain IN CNAME mydomain.com` means `subdomain.mydomain.com` points to the same destination as `mydomain.com`.

So, if you want to point `mydomain.com` to your server, you can do it by adding an `A` record pointing to your server's public IP address.

::warning

- __Warning:__ If your server is hosted at home:
- Your public IP is the one assigned to your home router. Make sure it's static, or configure [DDNS](https://aws.amazon.com/fr/what-is/dynamic-dns/).
- Make sure you've [set up port 443 forwarding to your server's listening port](/general/networking/nat).
::

If you're adding a subdomain that should also point to your server, use a `CNAME` record pointing to `mydomain.com`.

::note

__Why not use an `A` record for the subdomain?__ If your subdomain points to the same server as `mydomain.com`, it's better to use a `CNAME` record because if the server's IP changes, you won’t need to update the subdomain record.
::

Most registrars offer user-friendly interfaces to manage DNS records. Refer to your registrar’s documentation for specific instructions.
