There is a regular way to reset the DNS zone of each domain name from the WHM interface. However, it can be difficult and time-consuming to reset DNS zones one by one for all domains on the server through WHM.
Therefore, we recommend using the following command-line method to reset all DNS zones easily.
Before proceeding, make sure that screen is installed on your server. Running the process inside a screen session helps prevent interruption if your SSH session disconnects.
Install Screen
On CentOS/CloudLinux/RHEL:
yum install screen -y
Or on newer AlmaLinux/RockyLinux systems:
dnf install screen -y
Start a Screen Session
screen -S dnsreset
Reset DNS Zones for All Domains
Run the following command:
for i in $(cat /etc/trueuserdomains | cut -d: -f1); do
echo "Resetting DNS zone for: $i"
whmapi1 resetzone domain=$i
done
This command will automatically reset the DNS zone for all primary domains hosted on the server.
Reset DNS Zones Including Addon, Parked, and Subdomains
If you also want to reset DNS zones for addon domains, parked domains, and subdomains, use the following method.
Install jq
The command below requires jq for JSON parsing.
yum install jq -y
Or:
dnf install jq -y
Run the Advanced DNS Reset Command
for user in $(ls /var/cpanel/users); do
domains=$(uapi --user="$user" --output=json DomainInfo list_domains 2>/dev/null | \
jq -r '
.result.data.main_domain,
.result.data.addon_domains[],
.result.data.parked_domains[],
.result.data.sub_domains[]
' 2>/dev/null | sort -u)
for domain in $domains; do
[ -n "$domain" ] || continue
echo "Resetting DNS zone for: $domain"
whmapi1 resetzone domain="$domain"
done
done
This method retrieves all domains associated with each cPanel account and resets their DNS zones automatically.
Rebuild and Restart DNS Services
After resetting DNS zones, it is recommended to rebuild the DNS configuration and restart the DNS service.
/scripts/rebuilddnsconfig
/scripts/restartsrv_named
Verify Domains Before Resetting
To preview all primary domains before running the reset:
for user in $(ls /var/cpanel/users); do
grep '^DNS=' /var/cpanel/users/$user | cut -d= -f2
done
To inspect domains for a specific user:
uapi --user=username --output=json DomainInfo list_domains | jq
