2.9 KiB
navigation, title, main
navigation | title | main | ||
---|---|---|---|---|
true | DNS Zone |
|
:ellipsis{left=0px width=40rem top=10rem blur=140px}
Domain Names and DNS Zones
::alert{type="info"} 🎯 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.
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.
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. (...)
indicatesns1.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
meansmydomain.com
points to IP203.0.113.0
.subdomain IN CNAME mydomain.com
meanssubdomain.mydomain.com
points to the same destination asmydomain.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.
::alert{type="warning"} :::list{type="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.
- Make sure you've set up port 443 forwarding to your server's listening port. ::
If you're adding a subdomain that should also point to your server, use a CNAME
record pointing to mydomain.com
.
::alert{type="info"} :::list{type="info"}
- Why not use an
A
record for the subdomain? If your subdomain points to the same server asmydomain.com
, it's better to use aCNAME
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.