Peters School of Business · Assiniboine College · NETW-0014
2 hours · Lecture + Lab 3C · Config hierarchy, named.conf.local, zone database, SOA/NS/A/CNAME records
Bridge from DHCP to DNS
option domain-name "yourname.net". What does this do? And right now, if S2 tries to resolve s1.yourname.net — what happens?" — the client's DHCP client writes the domain suffix to its resolver config, but since there's no DNS server for yourname.net, resolution fails. Today we build the DNS server that makes that name work.BIND9 config hierarchy, zone file syntax, the trailing dot rule, record types
Part 1 — BIND9 config file hierarchy (8 min)
/etc/bind/. The entry point is named.conf — it does nothing itself except include three other files:
named.conf.options — global daemon behaviour: directory (cache location), forwarders (where to send unresolvable queries), allow-query (who can query), recursion (whether to resolve on behalf of clients), dnssec-validation.
named.conf.local — where we add our own zone declarations. Everything we configure this week goes here.
named.conf.default-zones — built-in zones (localhost, root hints). Touch this carefully.
named-checkconf — validates the syntax of all named.conf files. named-checkzone zonename file — validates a specific zone database file. Always run both before restarting BIND. A BIND daemon that fails to start due to a syntax error stops answering all DNS queries — validation prevents outages.Part 2 — Zone declaration in named.conf.local (5 min)
zone "yourname.net" {
type primary;
notify no;
allow-query { any; };
file "/etc/bind/db.yourname.net";
};
type primary — the older type master still works in BIND9 but is deprecated. Current best practice is primary and secondary.
Part 3 — Zone database file anatomy (12 min)
$TTL 2D — default time-to-live for records in this zone. 2D = 3 days. Clients cache records for this duration before re-querying.
@ IN SOA s1.yourname.net. hostmaster.yourname.net. ( — Start of Authority record. @ represents the zone origin (yourname.net). The SOA lists the primary nameserver and admin email (in dotted form — the first dot is an @). Five numbers inside the parentheses:
2024112101 — serial number. Convention: YYYYMMDDNN (date + two-digit revision). Increment every time the zone changes. Secondary servers only transfer if our serial is higher than theirs.
3600 — refresh. How often a secondary checks for serial changes (1 hour).
3600 — retry. How long a secondary waits before retrying a failed refresh (1 hour).
3600 — expire. How long a secondary serves stale data if the primary is unreachable (1 hour — normally this would be days).
3600 — minimum/negative cache TTL. How long a "name doesn't exist" response is cached.
@ NS s1 — Name Server record: s1 (which expands to s1.yourname.net) is the authoritative nameserver.
s1 A 192.168.50.1 — A record mapping s1 → IP.
yourname.net:
s1 — relative name — BIND appends the zone name → s1.yourname.net ✓
s1.yourname.net. — absolute FQDN (trailing dot) — used exactly as written ✓
s1.yourname.net — no trailing dot — BIND appends zone → s1.yourname.net.yourname.net ✗
www CNAME s1 → www.yourname.net resolves to whatever s1 resolves to.
@ MX 10 mail.yourname.net. → mail for yourname.net goes to mail.yourname.net.
Part 4 — Point systemd-resolved at S1 (5 min)
systemd-resolved as a local resolver. To make S1 and S2 use our new DNS server, edit /etc/systemd/resolved.conf on each server and add under [Resolve]: DNS=192.168.50.1. Restart: sudo systemctl restart systemd-resolved. Verify: resolvectl status.Lab 3C — Install BIND9, configure named.conf.local, build forward zone, verify with dig
Part 1 — Install BIND9 and configure options (15 min)
sudo apt install bind9 bind9utils bind9-doc. Check status: sudo systemctl status named. Note: the service is called named (the daemon name), not bind9./etc/bind/named.conf.options on S1. Inside the options { } block, add:
recursion yes;
allow-query { 192.168.50.0/24; 192.168.51.0/24; 172.17.0.0/16; localhost; };
forwarders { 172.17.0.1; 1.1.1.1; };
sudo named-checkconf. No output = no errors. Restart: sudo systemctl restart named.Part 2 — Add zone declaration (10 min)
/etc/bind/named.conf.local on S1. Add the zone declaration (use the student's actual name):
zone "yourname.net" {
type primary;
notify no;
allow-query { any; };
file "/etc/bind/db.yourname.net";
};
sudo named-checkconf. Fix any errors before proceeding.Part 3 — Create the zone database file (25 min)
sudo cp /etc/bind/db.local /etc/bind/db.yourname.net. Edit the new file: sudo nano /etc/bind/db.yourname.net.$TTL 2D
@ IN SOA s1.yourname.net. hostmaster.yourname.net. (
2024112101 ; serial (YYYYMMDDNN — update when changed)
3600 ; refresh
3600 ; retry
3600 ; expire
3600 ) ; minimum TTL
@ NS s1
s1 A 192.168.50.1
s2 A 192.168.50.2
s3 A 192.168.51.2
loghost A 192.168.50.1
www CNAME s1
sudo named-checkzone yourname.net /etc/bind/db.yourname.net. If it says "OK", proceed. If there are errors, read the message — it includes the line number and a description of the problem.sudo systemctl restart named. Check the BIND9 log for zone load confirmation: sudo journalctl -u named -n 20. Look for: zone yourname.net/IN: loaded serial XXXXXXXX.Part 4 — Verify and update DNS resolver (20 min)
nslookup s1.yourname.net 192.168.50.1. Should return 192.168.50.1. Test the CNAME: nslookup www.yourname.net 192.168.50.1. Should return s1's A record via the CNAME chain.dig @192.168.50.1 s2.yourname.net. Interpret the four sections: QUESTION (what was asked), ANSWER (the result), AUTHORITY (which server is authoritative), ADDITIONAL (glue records). Note the status field: NOERROR = found, NXDOMAIN = not found./etc/systemd/resolved.conf, set DNS=192.168.50.1. Restart: sudo systemctl restart systemd-resolved. Now: ping s2.yourname.net should resolve without specifying the server explicitly.loghost entry from S2's /etc/hosts that was added in Lab 2D. Verify: ping loghost still resolves — now via DNS instead of the hosts file.s1.yourname.net instead of s1.yourname.net.?" — BIND would append the zone name: s1.yourname.net.yourname.net — an invalid double-domain name.Learning outcomes — by end of Day 3, students can…
Common issues and fixes
| Issue | Likely cause | Fix |
|---|---|---|
| named-checkzone reports "not at top of zone" or "not fully qualified" | FQDN written without trailing dot in SOA or NS record | Any FQDN in a zone file that contains dots must end with a trailing dot. Short labels (like 's1') should have no dots at all |
| BIND9 starts but zone doesn't load — no "loaded serial" in log | named.conf.local not saved, or zone declaration has a syntax error | Run named-checkconf — it will show the line number of any error in named.conf.local |
| dig returns SERVFAIL instead of NOERROR | Zone file has errors that prevented loading | Check journal: sudo journalctl -u named -n 30. The load error will be there with the specific problem |
| www.yourname.net resolves to "server can't find" or NXDOMAIN | CNAME target (s1) doesn't have a trailing dot but looks like it might — or the zone wasn't reloaded after adding the CNAME | Verify CNAME: www CNAME s1 (no dot — relative). Reload after change: sudo systemctl reload named |