nsd-xfer bind to local IP

Hello,

I am busy on the last steps to integrate NSD with our setup, so that
we can move a nameserver (hopefully all of them) to NSD.

I noticed that it is not possible for nsd-xfer to create a socket with
an arbitrary local IP address. We slave zones from many master servers
which are not managed by ourselves. These people are all expecting our
AXFR's to come from a known IP which is not the interface's primary IP
(for various reasons, mainly that we can quickly move the nameserver
IP alias between machines in case of hardware failure).

So I created a small patch for NSD 2.3.0 to specify the source address
to nsd-xfer. It may be useful to others as well, so perhaps this*
could be included in a future release. (* = Or something which
functions like it, I won't say I am a world class C programmer) :slight_smile:

The patch adds a command line parameter to nsd-xfer:

  -a src Local hostname/IP for the connection.

Also it adds nsdxfer_flags to nsdc which can be set in nsdc.conf.

I have tested it only on FreeBSD 5.4 with IPv4. If you'd specify a
hostname which has both A and AAAA records, I'm pretty sure both
protocols would be handled correctly by taking res->ai_family of the
current server and passing it to gethostbyname2().

Any comments are welcome...

On FreeBSD, the following patch can be applied to /usr/ports/dns/nsd
after doing a "make extract".
http://www.lifeforms.nl/~walter/nsd-xfer_2.3.0_bindip.patch

PS: It seems that there were two leftovers called "namedxfer" in
Makefile.in and nsdc.conf.sample.in, I changed these to read "nsdxfer"
as well..

Cheers,
Walter Hop
Transip BV

It's a good idea, binding to a local IP is useful. The code isn't very
portable though :confused:

Don't use gethostbyname2(), use getaddrinfo(). Same goes for bzero and
bcopy, use memset and memcpy. bzero and bcopy arn't portable.

Walter Hop wrote:

On FreeBSD, the following patch can be applied to /usr/ports/dns/nsd
after doing a "make extract".
http://www.lifeforms.nl/~walter/nsd-xfer_2.3.0_bindip.patch

Thanks, I'll add this patch (modified for portability) to NSD.

Erik