DNS multi-server for VPS

pppplus

Verified User
Joined
Dec 19, 2008
Messages
526
I need some help, and explanations.

I install some VPS for different persons on my server.
I want configure nameservers like this :
nameserver 1 : Ip on their vps
nameserver 2 : Ip on the my IP of server, so something like this

domain.com NS vps001.server1.com (with IP 123.123.123.123)
domain.com NS s001.server1.com (with IP 111.222.333.444)

I find some howto explaining with public/private key how to do. But I don't want this, because it is not a good idea, vps001 can connect to server.

So my idea is :
- from server, do a cron,
* reading all domains in VPS
* when NS1 or NS2 is on server1, do a copy on server1

nothing is installed in server, except proxmox (bind is also installed).

Is it possible ? a good idea ? or is it totally stupid ?
 
Use multiserver function, if directadmin is running on both servers.
If not, please, search this forum. There's a ready solution from Jeff.
 
Thanks.
No directadmin do not run in server.

I think that I've already seen the post about multiserver here. And it is whith private/public key, and ssh connection between servers.

But I don't want VPS connect to the server. So I just want to run from server, check all VPS as to copy domains info.

Sorry if I am not clear, english is not my language, and my explanations are not so clear...
 
If you don't want to use SSH. You can use FTP to get list of zones from one server to another or even HTTPS. Anyway, your suggested step look good.

P.S. If I'm not mistaken, Jeff's solution use FTP, not SSH.
 
Ok, I will search a new time.
It is to use from ssh, but only on the server, I don't want VPS connect via ssh to the server.

So maybe, I can change jeff FTP solution to use.

Thanks
 
Thanks.
I've found it, and it was not what I want to use.
But there are some informations usefull in it to help me

I test my idea, and it works well.
The last one problem, is just to do a script sh.

I am writing it (but I am beginner for sh script), so it takes some time...
When it works, I will post it, maybe it can be usefull for some persons.
 
My solution uses http rather than ftp, but yes, a solution could use ftp as well.

Jeff
 
Tom, I don't see how you'd use PowerDNS. PowerDNS is available as an authoritative namesever, but I don't see how you could use it to manage DNS from different DirectAdmin servers on a multi-server configuration.

Jeff
 
I post what I've done.
Thanks to comment, or correct problems.

I want to use main server to as second nameserver for each VPS

So :
1- script goes in each VPS and copy each *.db files in /var/cache/bind
2- script copies each zone to a file
3- script copies all zone in a general file /etc/bind/named.master.conf

my script : /etc/bind/maj_bind.sh
Code:
#!/bin/sh 
cd /vz/root

namedpath='/var/named';
namedconf='/etc/named.conf';

for file in `ls /vz/root`
   do	echo "Server: $file";
	# list of VE
	if [ -d $file ]; then 
		echo " $file is a directory"
		# verif if directory /var/named/ exits, so copy all files in server
		directory=/vz/root/$file/var/named
		if [ -d $directory ]; then
			echo " $directory is a directory"
			#copie tous les fichiers .db
			cp $directory/*.db /var/cache/bind 	
			
			#read zone and put them in a file
			VPSnamedconf=/vz/root/$file/$namedconf
			VPSnamedpath=/vz/root/$file/$namedpath

			rm -f /etc/bind/named.$file.master.conf
			grep "^zone" $VPSnamedconf|grep -v '^#'|grep "type master" | sed 's_/var/named_/var/cache/bind_' >> /etc/bind/named.master.$file.conf
			
		fi
		
	fi
	echo '-----------$file--------------'
	done

#general zones
rm -f /etc/bind/named.master.conf

echo '-----------copy to /etc/bind/named.master.conf--------------'
for file in `ls /vz/root`
   do	echo "write general zones";
	# list of VE
	if [ -d $file ]; then 
		
		#read zone and put them in general file
		cat "/etc/bind/named.master.$file.conf"  >> /etc/bind/named.master.conf
		
	fi
	done
	echo '-----------copy done--------------'

I add in /etc/bind/named.conf
Code:
include "/etc/bind/named.master.conf";

in crontab I had :
Code:
5,15,25,35,45,55 * * * * root /etc/bind/maj_bind.sh > /dev/null 2> /dev/null
8,18,28,38,48,58 * * * * root /etc/init.d/bind9 reload > /dev/null 2> /dev/null

Some problems :
- if a domain is registered in several VPS, it would be a good idea to have an alert
- if VPS do not run directadmin, I have to change some things
- and all I have forgotten...

One question :
- in the file, for each zone, there is :
Code:
zone "domain" { type master; ...}
I have type master in VPS and in main server. Is it ok, or do I have to change to type slave ?

Thanks for your help and comments
 
Note I did not read your code; I'm only responding to specific parts of your post, below:
- if a domain is registered in several VPS, it would be a good idea to have an alert
I've got code in my Master2Slave DNS Replicator to manage that, but I'm not going to rewrite it for you to work on your system. You can look into it yourself.
- in the file, for each zone, there is :
Code:
zone "domain" { type master; ...}
I have type master in VPS and in main server. Is it ok, or do I have to change to type slave ?
You should NOT change it to type slave, as what you're really using is a replicated master. You're NOT using a Master->Slave configuration as I use in my Master2Slave DNS Replicator.

Jeff
 
thanks jlasman for answer about slave / master.

Yes I see you verify that on your script, but I do not understand all.
I am just a beginner in bash language...

understand script is very different to write it.
I will read new time your script, and call google again...
 
I didn't write it; I paid to have it written for me. It works, and I don't touch it. I could write one that would work, for a fee, but hopefully someone would offer to do that for you at no charge.

Jeff
 
Some small things added to my small and old script :

- now, I can delete Zone if they are in several VPS (if do not delete duplicate line, in /etc/bind/named.master.conf, bind stop to work)
- if a domain exists on several VPS, the oldest VPS erase zone in /var/cache/bind. I don't know what is the best solution, but I decide that oldest VPS are the best.

Code:
#!/bin/sh 
cd /vz/root

namedpath='/var/named';
namedconf='/etc/named.conf';

#for each VE, in reverse order (so oldest machine erase domaine in /var/cache/bind)
for file in `ls -r /vz/root`
   do	echo "Server: $file";
	# list of VE
	if [ -d $file ]; then 
		echo " $file is a directory"
		# verif if directory /var/named/ exits, so copy all files in server
		directory=/vz/root/$file/var/named
		if [ -d $directory ]; then
			echo " $directory is a directory"
			#copie tous les fichiers .db
			cp $directory/*.db /var/cache/bind 	
			
			#read zone and put them in a file
			VPSnamedconf=/vz/root/$file/$namedconf
			VPSnamedpath=/vz/root/$file/$namedpath

			rm -f /etc/bind/named.master.$file.conf
			grep "^zone" $VPSnamedconf|grep -v '^#'|grep "type master" | sed 's_/var/named_/var/cache/bind_' >> /etc/bind/named.master.$file.conf
			
		fi
		
	fi
	echo '-----------$file--------------'
	done

#general zones
rm -f /etc/bind/named.master.conf

echo '-----------copy to /etc/bind/named.master.conf--------------'
for file in `ls /vz/root`
   do	echo "write general zones";
	# list of VE
	if [ -d $file ]; then 
		
		#read zone and put them in general file
		cat "/etc/bind/named.master.$file.conf"  >> /etc/bind/named.master.confTEMP
		
	fi
	done
	echo '-----------copy done--------------'

# delete duplicate entries in /etc/bind/named.master.conf
cat "/etc/bind/named.master.confTEMP" | sort | uniq >> /etc/bind/named.master.conf
# delete /etc/bind/named.master.confTEMP
rm -f /etc/bind/named.master.confTEMP
 
If you read the Jeff thread of master2slave you would notice my solution i did implement based on Jeff solution that use rsync via ssh for syncing.

Maybe that is what would do what you need.

Regards
 
Hi Sellerone

You are one of the best persons in this forum, you help me several times in differents posts.

But this time, I do not understand you message :confused:

I have no question, I just send my new version of my small script, to duplicate VPS dns for secondary DNS.
I do that in this post, because, I open this one, and I already send a previous version.

So, it was just a better script than the previous (I do not compare my small script with master2slave).
My script is just to copy DNS of VPS in hypernode as secondary DNS
 
Ops, i didnt notice it was a very old thread :D

I meant that i did release in Jeff master2slave thread a customization of it that use rsync and ssh instead of http :)

But, since you got your solution you can definitly ignore my post :) My wrong ^^

Regards
 
Back
Top