Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section DNS Server
  • Search

Mass change of NS records

Questions regarding the DNS Server
BIND
Post Reply
  • Print view
Advanced search
7 posts • Page 1 of 1
Felix
Posts: 134
Joined: Tue Aug 04, 2015 7:15 pm

Os: Ubuntu 15x
Web: apache + nginx
Mass change of NS records
  • Quote

Post by Felix » Wed Feb 24, 2016 9:48 pm

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?
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Mass change of NS records
  • Quote

Post by tjebbeke » Thu Feb 25, 2016 8:09 am

You can use te API (check /usr/local/vesta/bin) to build a script. But it isn't possible in the UI.
Top

Felix
Posts: 134
Joined: Tue Aug 04, 2015 7:15 pm

Os: Ubuntu 15x
Web: apache + nginx
Re: Mass change of NS records
  • Quote

Post by Felix » Sat Feb 27, 2016 10:40 am

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
Top

skamasle
Collaborator
Posts: 592
Joined: Mon Feb 29, 2016 6:36 pm

Re: Mass change of NS records
  • Quote

Post by skamasle » Mon Feb 29, 2016 9:55 pm

You can go to

Code: Select all

/usr/local/vesta/data/users/USER/dns
And use some comand like:

Code: Select all

replace -v "DNS2 "DNS3" -- *
man replace

Then rebuild DNS from vestacp to that user.

If you edit it on /home/[user]/conf/dns/ vesta will overwrite that files.
Top

sacredwebsite
Posts: 29
Joined: Sun Dec 13, 2015 6:18 pm

Re: Mass change of NS records
  • Quote

Post by sacredwebsite » Wed Aug 31, 2016 4:00 am

For anyone looking to do this easily (for a single user):

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
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
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
Top

Rhandy
Posts: 30
Joined: Sat Nov 26, 2016 1:50 pm

Re: Mass change of NS records
  • Quote

Post by Rhandy » Tue Nov 29, 2016 10:42 pm

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 :
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


Top

Rhandy
Posts: 30
Joined: Sat Nov 26, 2016 1:50 pm

Re: Mass change of NS records
  • Quote

Post by Rhandy » Wed Nov 30, 2016 12:41 pm

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

Top


Post Reply
  • Print view

7 posts • Page 1 of 1

Return to “DNS Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password