Skip to main content

Secondary dns zone transfer from tinydns to bind

First create necessary users:
# useradd dnslog
# useradd axfrdns

axfrdns-conf command creates axfrdns configuration files and folders: (env, log, Makefile, run, tcp)
# axfrdns-conf axfrdns dnslog /etc/axfrdns /etc/tinydns <tiny dns server ip address>

Allow zone transfer for a bind server that contains secondary zone:
# echo '<bind dns server ip address>:allow,AXFR="<dns zone to allow>"' > /etc/axfrdns/tcp

In order to run make command tcprules should be installed:
# rpm -ivh daemontools-0.76-9.1.i386.rpm
# rpm -ivh ucspi-tcp-0.88-2.1.i386.rpm

make command creates tcp.cdb file:
# cd /etc/axfrdns
# make

run axfrdns tcpserver service:
# ./run

Dnsnotify is a perl script that is used to notify bind dns server about there is a zone update and once bind is triggered it would initiate zone transfer from tiny dns. From another command prompt on the tinydns server run this perl script. dnsnotify needs perl's Net::DNS package to be installed. It can be installed via cpan:
# perl -MCPAN -e shell;
cpan> install Net::DNS

Then run dnsnotify:
# ./dnsnotify

Dnsnotify script contents here: (you should set your axfrdns server ip address)
#!/usr/bin/perl -w
# usage: dnsnotify zone slave [...]
# example: dnsnotify example.org 1.2.3.4 1.2.3.5
# requires Net::DNS >= 0.20
use Net::DNS;
use Data::Dumper;
use strict;
my $MY_IP = "<tiny dns server ip address>"; # your own IP here
my $zone = shift;
die "usage: dnsnotify zone slave [...]\n"
  unless defined $zone and @ARGV;
my $res = new Net::DNS::Resolver;
$res->srcaddr($MY_IP);
for my $slave ( @ARGV ) {
  my $packet = new Net::DNS::Packet($zone, "SOA", "IN")
    or die "new Net::DNS::Packet failed\n";
$packet->header->opcode("NS_NOTIFY_OP");
  $packet->header->aa(1);
  $packet->header->rd(0);
  #$packet->print;
  $res->nameservers($slave);
  print STDERR Dumper($packet);
  my $reply = $res->send($packet);
  if ( defined $reply ) {
    $reply->print;
  } else {
    warn "\n;; TIMED OUT\n";
  }
}
exit 0;

Comments

Popular posts from this blog