We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
Mass change of NS records
Mass change of NS records
Vesta CP0.9.8R15 on Ubuntu 14.04
I have created USER1 and set DNS1 and DNS2 as the user's DNS servers. Every domain created by USER1 has DNS1 and DNS2 as NS records. At some point there was a need to change DNS2 to DNS3, so I went to edit the user in VESTA and replaced DNS2 with DNS3. But that didn't change the NS records in every domain owned by USER1.
Is there a way to massively change the NS records of every domain owned by USER1?
I have created USER1 and set DNS1 and DNS2 as the user's DNS servers. Every domain created by USER1 has DNS1 and DNS2 as NS records. At some point there was a need to change DNS2 to DNS3, so I went to edit the user in VESTA and replaced DNS2 with DNS3. But that didn't change the NS records in every domain owned by USER1.
Is there a way to massively change the NS records of every domain owned by USER1?
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: Mass change of NS records
You can use te API (check /usr/local/vesta/bin) to build a script. But it isn't possible in the UI.
Re: Mass change of NS records
A script is indeed a great idea but I'm no bash guru :-(
If anyone reading this could drop some help would be nice...
This could be the logic of the script but I can't code it:
v-script [user]
[user] argument should be used to check for files in directory /home/[user]/conf/dns/
for every file that is there, there should be a search and replace; search for DNS2 and replace with DNS3 in the line that contains "NS"
save each file
If anyone reading this could drop some help would be nice...
This could be the logic of the script but I can't code it:
v-script [user]
[user] argument should be used to check for files in directory /home/[user]/conf/dns/
for every file that is there, there should be a search and replace; search for DNS2 and replace with DNS3 in the line that contains "NS"
save each file
Re: Mass change of NS records
You can go to
And use some comand like:
man replace
Then rebuild DNS from vestacp to that user.
If you edit it on /home/[user]/conf/dns/ vesta will overwrite that files.
Code: Select all
/usr/local/vesta/data/users/USER/dns
Code: Select all
replace -v "DNS2 "DNS3" -- *
Then rebuild DNS from vestacp to that user.
If you edit it on /home/[user]/conf/dns/ vesta will overwrite that files.
-
- Posts: 29
- Joined: Sun Dec 13, 2015 6:18 pm
Re: Mass change of NS records
For anyone looking to do this easily (for a single user):
Or if you want to run this on all users:
Code: Select all
#!/bin/bash
if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;
fi
echo "Enter Old IP" && read ip_old
echo "Enter New IP" && read ip_new
echo "Enter User Name" && read user
sed -i "s/${ip_old}/${ip_new}/g" /usr/local/vesta/data/users/${user}/dns/*
v-rebuild-dns-domains ${user}
exit 0
Code: Select all
#!/bin/bash
if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;
fi
echo "Enter Old IP" && read ip_old
echo "Enter New IP" && read ip_new
declare -a user=$(v-list-sys-users plain)
for user in ${user[@]}; do
sed -i "s/${ip_old}/${ip_new}/g" /usr/local/vesta/data/users/${user}/dns/*
v-rebuild-dns-domains ${user}
done
exit 0
Re: Mass change of NS records
Hello
Your script give on excelent idea for update dynamic dns. can you help me and change the script to:
I dont know write shell script
But i can get ip using this :
Your script give on excelent idea for update dynamic dns. can you help me and change the script to:
I dont know write shell script
But i can get ip using this :
curl http://ipecho.net/plain; echo
Code: Select all
#!/bin/bash
if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;
fi
ip_old= ### one file saved before with old_ip
ip_new= ### something like this ## curl http://ipecho.net/plain; echo
declare -a user=$(v-list-sys-users plain)
for user in ${user[@]}; do
sed -i "s/${ip_old}/${ip_new}/g" /usr/local/vesta/data/users/${user}/dns/*
v-rebuild-dns-domains ${user}
### save this new ip to file old_ip for next use###
done
exit 0
Re: Mass change of NS records
Ok I´m done
:-)
:-)
Code: Select all
#!/bin/bash
if [ $(whoami) != 'root' ]; then
echo "Must be root to run $0"
exit 1;
fi
ip_old=`cat oldip`
ip_new=`curl http://ipecho.net/plain`
declare -a user=$(v-list-sys-users plain)
for user in ${user[@]}; do
sed -i "s/${ip_old}/${ip_new}/g" /usr/local/vesta/data/users/${user}/dns/*
v-rebuild-dns-domains ${user}
done
echo $ip_new >oldip
exit 0