> For the complete documentation index, see [llms.txt](https://security.navidnaf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://security.navidnaf.com/potions/computer-networking/dns/primary-secondary.md).

# Primary-Secondary

**Redundant DNS Servers**: These are backup DNS servers that ensure continuous availability and reliability by taking over if the primary DNS server fails.

## Primary DNS Server

This server holds all the zone information for a domain and is responsible for making and storing updates to the domain's DNS records.&#x20;

`ns1.example.com` is the primary DNS server for `example.com`.

## Secondary DNS Server

This server receives a read-only copy of the zone information from the primary DNS server and helps distribute the load and provide redundancy. It gets updates via **zone transfers** from the primary server.

If `ns1.example.com` is the primary DNS server, `ns2.example.com` could be the secondary DNS server for the `example.com` domain.

## Zone Information

This is the data associated with a domain, including DNS records such as A records (IP addresses), MX records (mail servers), and CNAME records (canonical names).

```dns-zone-file
; Zone file for example.com

$TTL 86400 ; Default TTL (Time to Live) of 1 day

; SOA Record
@    IN    SOA    ns1.example.com. admin.example.com. (
              2024091201 ; Serial (YYYYMMDDNN format)
              3600        ; Refresh (1 hour)
              1800        ; Retry (30 minutes)
              1209600     ; Expire (14 days)
              86400       ; Minimum TTL (1 day)
              )

; Name Servers
@    IN    NS     ns1.example.com.
@    IN    NS     ns2.example.com.

; A Records
@                IN    A      192.0.2.1
www              IN    A      192.0.2.1
ftp              IN    A      192.0.2.2

; MX Records
@                IN    MX     10 mail.example.com.

; CNAME Records
blog             IN    CNAME  www.example.com.

; TXT Records
@                IN    TXT    "v=spf1 include:_spf.example.com ~all"
```

## Zone Transfer

This is the process by which a secondary DNS server receives a copy of the zone information from the primary DNS server. It can be a **full transfer (AXFR)** or **incremental transfer (IXFR)**.

## Invisibility

Primary and secondary DNS servers are invisible to end users because they operate in the background to translate domain names into IP addresses automatically. Users interact with domain names and websites directly, while DNS servers handle the resolution process behind the scenes. Local caching on users' devices also reduces the need to frequently query DNS servers, making their role seamless and unnoticed.
