Part ARecords
What a record is
A DNS record (also called a resource record) is one entry in a domain's zone. Each has a name, a TTL, a class (always IN, "internet", in practice), a type that decides what the value means, and the value. Here is Kadé's zone in the standard zone-file format:
; kade.lk zone, hosted in GCP Cloud DNS ; name TTL class type value kade.lk. 21600 IN SOA ns-cloud-a1.googledomains.com. cloud-dns-hostmaster.google.com. 3 21600 3600 259200 300 kade.lk. 21600 IN NS ns-cloud-a1.googledomains.com. kade.lk. 21600 IN NS ns-cloud-a2.googledomains.com. ; + a3, a4 kade.lk. 300 IN A 34.87.120.15 www.kade.lk. 300 IN CNAME kade.lk. api.kade.lk. 300 IN A 34.87.120.15 kade.lk. 3600 IN MX 1 smtp.google.com. kade.lk. 3600 IN TXT "v=spf1 include:_spf.google.com include:sendgrid.net ~all" google._domainkey.kade.lk. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh…" _dmarc.kade.lk. 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@kade.lk" kade.lk. 3600 IN CAA 0 issue "pki.goog"
The record types you need
| # | Type | Maps a name to | Kadé example |
|---|---|---|---|
| 1 | A | An IPv4 address | api.kade.lk → 34.87.120.15 |
| 2 | AAAA | An IPv6 address ("quad A": 4× the size) | added once Kadé serves IPv6 |
| 3 | CNAME | Another name (an alias) | www.kade.lk → kade.lk |
| 4 | MX | The mail servers that receive email for the domain | kade.lk → smtp.google.com |
| 5 | NS | The authoritative name servers | kade.lk → ns-cloud-a1…a4 |
| 6 | TXT | Free text: verification and email security | SPF, DKIM, DMARC |
| 7 | SOA | Facts about the zone itself | one per zone (section 8) |
| 8 | PTR | An IP back to a name (reverse DNS) | section 8 |
| 9 | SRV | Host and port for a named service | section 8 |
| 10 | CAA | Which certificate authorities may issue TLS certificates | only Google's CA for kade.lk |
A and AAAA
The basic records: name → address. A few things worth knowing:
- One name, several addresses. A name can have several A records. Clients get the list, usually in a rotating order (round-robin DNS), which spreads load crudely. It does not check whether each server is healthy; a load balancer does that properly.
- Both families. A name can have A and AAAA records at the same time. Modern clients try IPv6 and IPv4 in parallel and use whichever connects first ("Happy Eyeballs").
- The apex (kade.lk itself, with no prefix) can have A and AAAA records like any other name.
CNAME
A CNAME (canonical name) says "this name is really that other name; look that one up instead". The resolver follows the chain and returns the final address:
| 1 | www.kade.lk → CNAME → kade.lk |
| 2 | kade.lk → A → 34.87.120.15 |
| ✓ | The browser gets 34.87.120.15. Change kade.lk's A record and www follows automatically. |
CNAMEs are also how you point a name at someone else's service: shop.kade.lk CNAME kade-store.hosted-shop.example. If that service changes its IPs, your record keeps working.
MX
An MX (mail exchanger) record says which servers receive email for the domain. When a shopper replies to an order email, their mail server does this:
The “please recurse” steps from chapter 22 are hidden: the resolver may already have most of this cached.
- The number is a priority: lower is tried first. With several MX records, others are backups. Google Workspace today uses a single record,
1 smtp.google.com. - An MX must point to a name with A/AAAA records, never to a CNAME or a bare IP.
- MX only controls receiving. Sending is covered by SPF and DKIM (Part B).
NS and delegation
NS records name the authoritative servers for a zone. They appear in two places, and both must agree:
| In the parent (.lk) | The delegation: "kade.lk is served by ns-cloud-a1…a4". Set through the domain registrar. This is what resolvers follow (chapter 22). |
| In the zone itself | The same list, served by Cloud DNS. Resolvers trust these once they arrive. |
You can also delegate a sub-zone: NS records for dev.kade.lk pointing to other servers hand that whole branch to someone else, the same way .lk handed kade.lk to Cloud DNS.
TXT
TXT records hold free text. DNS does not care what is in them; other systems read them. Two common uses:
- Proving you own a domain. Google, Microsoft or a certificate authority says "add this random string as a TXT record". Only the domain's owner can do that, so it proves control. Example:
google-site-verification=3fK9…. - Email security. SPF, DKIM and DMARC all live in TXT records (Part B).
Each string in a TXT record can be at most 255 characters; longer values (like DKIM keys) are split into several quoted strings that are joined back together.
SOA, PTR, SRV and CAA
| # | Type | What it holds | Why you care |
|---|---|---|---|
| 1 | SOA (start of authority) | One per zone: the primary server, an admin contact, a serial number, timers, and the negative-caching TTL (the last number, 300 s for kade.lk) | That last number is how long "name does not exist" is cached (chapter 22) |
| 2 | PTR (reverse DNS) | IP → name. 34.87.120.15 is looked up as 15.120.87.34.in-addr.arpa | Mail servers check that a sending IP has a sensible reverse name. Controlled by whoever owns the IP (for a GCP external IP, set in GCP), not in your zone. |
| 3 | SRV (service) | Host and port for a service: _sip._tcp.kade.lk → 10 5 5060 sip.kade.lk | Used by VoIP, chat and some directory services to find servers and ports by name |
| 4 | CAA (certificate authority authorization) | Which certificate authorities may issue TLS certificates for the domain | A CA must refuse to issue for kade.lk unless it is listed. Here only Google Trust Services (pki.goog), used by Google's load balancers. Reduces the risk of a wrongly issued certificate (TLS chapter). |
Part BEmail security
Why email is easy to fake
Email is sent with SMTP, a protocol from 1982 that trusts whatever the sender writes. Anyone can run a mail server and send a message with From: payments@kade.lk. The shopper's mail app shows "Kadé Payments" and the scam begins: "your order failed, re-enter your card here".
An email also has two sender addresses, which matters for what follows:
| Address | Where it lives | Who sees it |
|---|---|---|
| Envelope senderalso "Return-Path" or "MAIL FROM" | The SMTP conversation between servers; where bounces go | Servers only |
| Header From | The From: line inside the message | The person reading the email |
Three DNS-based checks close the gap. Each is a TXT record Kadé publishes, and receiving servers read it:
SPF
Which servers may send for this domain.
DKIM
A signature proving the message came from the domain, unchanged.
DMARC
The policy that ties both to the visible From, and says what to do on failure.
SPF: who may send
SPF (Sender Policy Framework) is a TXT record listing the servers allowed to send email for the domain. The receiving server checks whether the connecting IP is on the list:
kade.lk. TXT "v=spf1 include:_spf.google.com include:sendgrid.net ~all"
| v=spf1 | "This is an SPF record" |
| include:_spf.google.com | Also allow every server Google lists for Workspace (staff mail) |
| include:sendgrid.net | Also allow the bulk email provider (order and marketing emails) |
| ip4:198.51.100.20 | (optional) allow one IP directly, e.g. a printer that emails scans from the office |
| ~all | Everything else: "softfail" (suspicious). -all = hard fail; ?all = no opinion. |
- SPF checks the envelope sender, not the visible From. On its own it does not stop a fake
From:line. DMARC fixes that (section 12). - At most 10 DNS lookups. Each
includecan contain more. Past 10 the whole check errors out, a common mistake as companies add services. - Breaks on forwarding. When a mailing list or a forwarding rule resends the message, it arrives from the forwarder's IP, which is not on Kadé's list.
- Only one SPF record per domain. Two TXT records starting with
v=spf1make both invalid.
DKIM: a signature on every email
DKIM (DomainKeys Identified Mail) adds a cryptographic signature to each outgoing email. The sending service keeps a private key; Kadé publishes the matching public key in DNS. The receiver fetches it and checks the signature:
- The selector (
s=google) picks which key to fetch:google._domainkey.kade.lk. Different services use different selectors (e.g.s1._domainkeyfor the bulk provider), so each can have its own key, and keys can be rotated. - What it proves: the signing domain (
d=kade.lk) sent it, and the signed headers and body were not changed on the way. - Survives forwarding as long as nobody edits the message. A mailing list that adds "[list]" to the subject or a footer breaks it.
DMARC: alignment and policy
DMARC (Domain-based Message Authentication, Reporting and Conformance) ties SPF and DKIM to the address the reader actually sees. Its key idea is alignment: a passing check only counts if its domain matches the header From domain.
_dmarc.kade.lk. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@kade.lk"
| DMARC passes when | SPF passes and its domain aligns with the From domain, or DKIM passes and its d= domain aligns. One aligned pass is enough. |
| p=none | Monitor only: deliver normally, but send reports |
| p=quarantine | Failing mail goes to spam |
| p=reject | Failing mail is refused outright |
| rua=mailto:… | Where receivers send daily summary reports: which IPs sent mail as kade.lk and whether it passed. This is how Kadé discovers services it forgot to add to SPF. |
| Relaxed alignment | (the default) a subdomain counts: an envelope sender at em.kade.lk aligns with From kade.lk |
Try it: will this email get through?
Pick an email and a DMARC policy. The receiving server's checks run step by step:
- Sent from IP
- 209.85.220.41 (a Google mail server)
- Envelope sender
- orders@kade.lk
- Header From (seen)
- orders@kade.lk
| Check | Result | For domain | Aligned with kade.lk? | Why |
|---|---|---|---|---|
| SPF | pass | kade.lk | yes | 209.85.220.41 is in _spf.google.com, which kade.lk's SPF includes |
| DKIM | pass | kade.lk | yes | signature checked with the key at the signing domain |
| DMARC | pass | kade.lk | an aligned check passed | The normal case. Both checks pass and both are for kade.lk, the same domain the reader sees. |
Delivered to the inbox.
Reading the results in a real email
In Gmail, open a message and choose "Show original". The receiving server writes its verdicts into an Authentication-Results header:
Authentication-Results: mx.google.com; dkim=pass header.i=@kade.lk header.s=google; spf=pass (google.com: domain of orders@kade.lk designates 209.85.220.41 as permitted sender) smtp.mailfrom=orders@kade.lk; dmarc=pass (p=QUARANTINE) header.from=kade.lk
Summary
| # | Idea | In one line | New terms |
|---|---|---|---|
| 1 | Record | Name, TTL, class, type, value; a zone is a set of them | resource record, zone file |
| 3 | A / AAAA | Name → IPv4 / IPv6; several = round-robin | round-robin DNS |
| 4 | CNAME | Alias; no other records beside it; not at the apex | apex, CNAME flattening |
| 5 | MX | Mail servers for receiving; lower number first | MX priority, SMTP |
| 6 | NS | Authoritative servers; parent and child must agree | delegation |
| 7 | TXT | Free text: ownership proof, email security | |
| 8 | Others | SOA (zone facts, negative TTL), PTR (reverse), SRV (service), CAA (allowed CAs) | SOA, PTR, SRV, CAA |
| 9 | Spoofing | SMTP trusts the sender; envelope vs header From | envelope sender |
| 10 | SPF | Allowed sending IPs; checks the envelope; 10-lookup limit | SPF |
| 11 | DKIM | Signature; public key at selector._domainkey | DKIM, selector |
| 12 | DMARC | Aligned SPF or DKIM pass; none → quarantine → reject; reports | DMARC, alignment |
Try it yourself
IPv4 and IPv6 records
- Steps:
dig google.com A,dig google.com AAAA - What to look for: Different addresses for the same name.
- From section: 2. The record types you need
dig google.com Adig google.com AAAAA CNAME chain
- What to look for: A CNAME line, then the A record of its target.
- From section: 4. CNAME
dig www.github.comMail servers
- What to look for: Several lines with priorities (5, 10, 20 …).
- From section: 5. MX
dig gmail.com MX +shortAuthoritative servers
- What to look for: The provider's name servers.
- Runs on: try with any real domain
- From section: 6. NS and delegation
dig kade.lk NS +shortTXT records
- What to look for: A
v=spf1 …line and verification strings. - From section: 10. SPF: who may send
dig google.com TXT +shortA DMARC policy
- What to look for:
v=DMARC1; p=reject; … - From section: 12. DMARC: alignment and policy
dig _dmarc.google.com TXT +shortA DKIM public key
- What to look for:
v=DKIM1; k=rsa; p=… - From section: 11. DKIM: a signature on every email
dig google._domainkey.kade.lk TXT +shortReverse DNS (PTR)
- What to look for:
dns.google. - From section: 8. SOA, PTR, SRV and CAA
dig -x 8.8.8.8 +shortAllowed certificate authorities
- What to look for:
0 issue "pki.goog" - From section: 8. SOA, PTR, SRV and CAA
dig google.com CAA +shortAll records in a Cloud DNS zone
- What to look for: The same records as the zone file in section 1.
- From section: 1. What a record is
gcloud dns record-sets list --zone=kade-lk