A, CNAME, MX, TXT : à quoi sert vraiment chaque enregistrement DNS
Ouvrir la zone DNS de son domaine pour la première fois, c'est tomber sur un tableau de sigles sans explication. En réalité il n'y a que quatre lignes à comprendre, et elles suffisent pour 95 % des situations. A : le domaine pointe vers une machine C'est l'enregistrement de base. Il associe un nom à une adresse IP. creebs.fr. 3600 IN A 109.234.165.64 À lire ainsi : le nom creebs.fr mène à la…
DNS settings can appear confusing when first encountered, but they are actually quite simple and cover 95% of situations. There are four key records: A, CNAME, MX, and TXT.
The A record points your domain to a specific machine. For example, "creebs.fr. 3600 IN A 109.234.165.64" means that the domain creebs.fr leads to the machine with IP address 109.234.165.64, and this information is valid for 3600 seconds. IPv6 addresses use the AAAA record for the same purpose. If your hosting provider offers AAAA support, use both A and AAAA records.
The CNAME record is essentially another name. It doesn't point to a machine, but to another name, which in turn gets resolved. For instance, "www.creebs.fr. 3600 IN CNAME creebs.fr" associates the subdomain www.creebs.fr with the main domain creebs.fr. This is useful for maintaining records, as changing the A record automatically updates all CNAME records pointing to it.
However, a CNAME cannot coexist with another record under the same name. The top-level domain usually uses an A record, while the root domain cannot be a CNAME due to existing MX and service records.
MX records specify where your emails are received. They are independent of the site and can be hosted at different providers. For example, "creebs.fr. 3600 IN MX 10 mail.creebs.fr. creebs.fr. 3600 IN MX 20 secours.creebs.fr" means that emails for creebs.fr are received by mail.creebs.fr with priority 10, and secours.creebs.fr with priority 20, which only kicks in if 10 fails. Forgetting to update MX records during a site migration is a costly mistake, as emails may be sent to a non-existent server.
TXT records contain free-form text and are mainly used for two purposes: proving domain ownership and email authentication. For example, "creebs.fr. 3600 IN TXT v=spf1 include:_spf.o2switch.net -all" sets up SPF to list authorized servers for sending emails and DKIM to sign emails, ensuring they haven't been altered. Another TXT record, DMARC, tells receivers what to do when SPF or DKIM fail. Without these, a new domain may see many emails end up in the spam folder without explanation.
In summary, to set up your DNS correctly:
- Point the domain to a server using an A record, and include AAAA for IPv6.
- Point www to the main domain using a CNAME.
- Receive emails using MX records, along with SPF, DKIM, and DMARC TXT records proving domain ownership.
- Use TXT records provided by service providers for subdomains.
- Avoid placing a CNAME on the root domain, as it can cause MX records to become hidden. Double-check for a period at the end of your domain in the DNS zone, as some interfaces add it automatically. Maintain lower TTL values before making changes during a migration to avoid prolonged cache issues. If your DNS zone appears complex, consider professional assistance.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.