Creating master/slave dns with two DA servers

synergy

Verified User
Joined
Nov 8, 2003
Messages
48
Location
Australia
If I have two DA servers, in different geographical locations with the following details:

ServerA.com IPs: 1.1.1.1 and 1.1.1.2

ServerB.com IPs: 2.2.2.1 and 2.2.2.2

I want to setup master / slave dns between them in case one of them is down.

- Do I assign one IP address to each domain on each server? i.e. serverA has the 1.1.1.x addresses so on serverA I create one name server for itself (ns1.serverA.com with 1.1.1.1) and one name server for serverB (ns1.serverB.com is 1.1.1.2) then vice-versa on serverB?
- How do I use the zone.conf template file?
- What else am I missing?

Any help would be appreciated. Thank you.
 
Last edited:

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
I plan to set up a DNS Server to manage DNS for at least three DA servers (and possibly a few cpanel servers). Not that it's dire important at this moment, but I'm curious, does anyone know what specifications this "DNS Server" will need? I am simply not sure how much "power" is required.

I imagine I'd also like to set it up so that if my DNS Server goes down it will automatically start using one of the other DA or CPanel servers as a temporary DNS Server.

Those are my plans anyway :)
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
As with most other control panels DNS is not automated when this is done.

You would basically have to remove all DNS records from a site within DirectAdmin, and set them all up on your DNS server resolving to the appropriate IP addresses.

Note that this would need to be done every time a site was created and this is only a simple description of how it would work in the long run.

Chris
 

synergy

Verified User
Joined
Nov 8, 2003
Messages
48
Location
Australia
Maybe I am asking the wrong question...what is the zone.conf file from this thread for? It sounds to me like you could let DA automate the DNS creation and then cron could fetch the zone.conf file for the slave server to use. I assume it would still be automated then as long as you had the master / slave ns records setup in the first place. Am I on the right track? Thanks.
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
The main file you would need is:

/var/named/DOMAIN.COM.db

That file should contain information such as records, refresh retry and expire times for the domain.

An easier way to do things would be to use the custom script feature upon domain creation / deletion which adds domains to a database, then create a script on your DNS server which checks that database for any domains, which do not exist, if they already exist leave them if the domain does not exist use a default 'template' of DNS records which can be modified later if required.

That would be the easiest way to at minimum, partially automate the process.

I suggest if you dont know what your doing that you read up on this topic firstly - google should help you with this.

Chris
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
With DNS it would be nice if you could (on the "DNS Server") do ::
Code:
if accessing *.domain.com {
      forward_request_to_server_housing_domain.com();
}
Then when a domain is added to one of the servers, one of the above records would be appended to the "DNS Server"
 

jdwright

Verified User
Joined
Oct 19, 2003
Messages
18
I just have something like this for each doman on my backup dns. It be nice if I could automate this so it would add each new domain I added to DA on the main machine, but I lack shell scripting skills.

Code:
zone "example.com" {
        type slave;
        file "/var/named/example.com.bkupns.db";
        masters {111.111.111.111; };
};
Then it automatically updates with the main DA machine at whatever time I set in the /etc/named.conf on that machine.
 

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
That is cool!

I am sure it would not be too hard to design a script that could do the updating, although I am not quite sure how it would work. Could the DA server simply wget or something a file on the DNS server as "http://the.dns.server/blah.pl?security_key=foo&add_domain=domain.com", or something. Maybe you could FTP/SSH in and do somewhat the same, I'm not sure.

This is something definitely needed though.
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
Could be done *VERY* easily..... use the upon domain creation scripts, write a file using the domain variable (the list of records) place it in a protected directory and then wget it passing the GET variables in the wget.

you could even forget the password protection and disallow all access to the directory apart from the IP of your DNS server which should also work fine and be just as safe.

As i said, it should be fairly simple to setup. You simply need time to write the script and knowldge of how it would work.

Chris
 

ProWebUK

Verified User
Joined
Jun 9, 2003
Messages
2,326
Location
UK
if all you need is /var/named/DOMAIN.COM.db

then simply write a shell script to run every X in cron:

Main server 1
# remove any previous backups that exist
rm -f slavedns.tar.gz
# compress your named directory in tar.gz format
tar -czvf slavedns.tar.gz /var/named/
# move the backup to be accessable via the web
mv slavedns.tar.gz /var/www/html/protected/slavedns.tar.gz

DNS server
# remove any previous backup files
rm -f slavedns.tar.gz
# Get the latest backup file
wget http://server1_IP_address/protected/slavedns.tar.gz
# Make a backup of your previous DNS entries
cp /var/named/ /var/named/backup/
# untar your latest entries to /var/named
tar -zxvf slavedns.tar.gz

You would need to set them up as shell scripts with the headers etc but thats waht you need, them exatc commands in order should do the trick :)

Chris
 
Top