Introduction
If your server previously did not have the correct nameservers configured before accounts were transferred to it, or if you need to update the nameservers for all domains, this article describes how to do that. cPanel does not provide a utility to do this across all domains; however, it does have a script that can be looped to update the nameservers for each domain on a cPanel server.
Procedure
Use the following one-liner to change all domains hosted on a cPanel server, replacing ns1.example.com ns2.example.com with the new nameservers:
for user in `ls /var/cpanel/users |grep -v \/`; do /scripts/xfertool --changenameservers $user ns1.example.com ns2.example.com; done
The following can be used to change the nameservers for a particular reseller. Change the ns1, ns2, and reseller variables as needed:
ns1=ns1.domain.tld; ns2=ns2.domain.tld; reseller=reseller
for i in `grep -H ^OWNER=$reseller /var/cpanel/users/* |cut -d: -f1 |cut -d/ -f5 |sort`; do /scripts/xfertool --changenameservers $i $ns1 $ns2; done
If you want to change the nameservers for a single user, run the script for that user like so:
/scripts/xfertool --changenameservers user ns1.example.com ns2.example.com