An operator with root SSH access edits /var/named/example.com.db with vi to fix a syntax issue cPanel won’t expose. The edit is correct. named-checkzone passes. rndc reload succeeds. But the next time the customer adds a record via the Zone Editor, cPanel rewrites the zone from its internal database and the direct edit disappears. Direct editing isn’t forbidden — but it has to be coordinated with what cPanel thinks the zone should look like.
What’s happening
cPanel stores authoritative zone state in two places:
/var/named/example.com.db— the BIND zone file thatnamedactually serves.- cPanel’s internal metadata (in
/var/cpanel/zonetemplates/and the user’scpanel.config-equivalent) that drives the Zone Editor UI.
When you edit through the Zone Editor or whmapi1 addzonerecord, cPanel writes both. When you edit /var/named/example.com.db directly, cPanel only sees the BIND view — its internal metadata is stale. The next UI edit triggers a regeneration that overwrites your direct change.
Direct edits also bypass the cluster sync. cPanel’s dnsadmin triggers a peer push when the zone is modified through the API. A vi edit doesn’t trigger that — the file changes locally, but peers don’t know.
There are still legitimate cases for direct editing:
- A syntax error in the file that cPanel’s UI won’t let you correct (cPanel’s parser refuses the file, the UI shows blank).
- A record type cPanel doesn’t expose at all (rare, but happens with experimental types).
- Bulk operations across many zones where the UI would be impractically slow.
How to verify
Confirm what the live zone file looks like:
named-checkzone example.com /var/named/example.com.db
grep -c '^[a-z]' /var/named/example.com.db
Confirm cPanel’s internal view matches:
whmapi1 dumpzone domain=example.com
diff <(named-compilezone -o - example.com /var/named/example.com.db | sort) \
<(whmapi1 dumpzone domain=example.com --output=jsonpretty | jq -r '.data.zone[].record[]' | sort)
If the two views disagree, cPanel and BIND have drifted.
Check cluster sync:
ssh peer "dig +short SOA example.com"
ssh local "dig +short SOA example.com"
If serials differ, the peer didn’t get your direct edit.
What to do
- Always prefer the Zone Editor or
whmapi1for routine edits. Both keep cPanel’s view consistent withnamedand trigger cluster sync. - For unavoidable direct edits, follow this sequence:
- Take a backup:
cp /var/named/example.com.db /var/named/example.com.db.$(date +%Y%m%d-%H%M).bak - Edit the file.
- Increment the SOA serial manually if you’re editing past whatever cPanel will see — otherwise
namedwon’t reload, and cluster peers won’t take the update. Format isYYYYMMDDNN. named-checkzone example.com /var/named/example.com.db— must pass.rndc reload example.com— reloadsnamed.- Force cluster sync:
/scripts/dnscluster synczone example.com. - Force cPanel to re-read the zone:
/scripts/updateuserdomainsthenwhmapi1 dumpzone domain=example.comto confirm cPanel now sees what’s on disk.
- Take a backup:
- For bulk changes across many zones, write a script that uses
whmapi1repeatedly, not one that edits files directly:
for zone in $(whmapi1 list_zones --output=jsonpretty | jq -r '.data.zone[]'); do
whmapi1 editzonerecord domain=$zone Line=N name=$zone. ttl=300 type=A address=192.0.2.10
done
This keeps cluster sync in step.
- After any direct edit, log what you did and why. cPanel’s UI has no audit trail for
viedits. A note in/etc/motdor your team’s runbook prevents the next operator from wondering why a record looks different from the rest.
If you find yourself doing direct edits often, that’s a signal cPanel’s UI is the wrong tool for the task. Consider migrating to a DNS provider with an API that handles bulk operations cleanly, or scripting against whmapi1 instead of vi.
Stack Harbor minimizes direct zone edits in favor of API-driven changes as part of WHM server management.