lost and found ( for me ? )

install gdnsd 1.8.1 on ubuntu 12.04


about gdnsd


In short , gdnsd is GEO-aware authoritative DNS server.
You can configure GEO-IP based balancing , redirection etc.
Here’s an explanation of how to install gdnsd and register zones.(basic configuration)

[ install gdnsd on ubuntu ]

# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
# uname -ri
3.2.0-40-virtual x86_64

install some packages to build gdnsd.
apt-get install ragel build-essential libboost-test-dev g++ cmake git eog

download gdnsd from http://downloads.gdnsd.net

I build gdnsd from source code.
# xz -dv gdnsd-1.8.1.tar.xz
# tar xvf gdnsd-1.8.1.tar
# cd gdnsd-1.8.1
# ./configure
# make
# make install

# /usr/local/sbin/gdnsd --version
gdnsd version 1.8.1

[ configure gdnsd ]

basic configuration
# cat /usr/local/etc/gdnsd/config
options => {
   log_stats => 86400
   tcp_timeout => 15 ; zonefile-style comment
   include_optional_ns => true
   listen => [ 127.0.0.1, 192.168.10.237 ]
   http_listen => [ 127.0.0.1, 192.168.10.237 ]
}

plugins => {
 null => {}
}

check syntax
# /usr/local/sbin/gdnsd checkconf
Loading configuration
DNS listener configured for 127.0.0.1:53
DNS listener configured for 192.168.10.237:53
User 'gdnsd' does not exist

add gdnsd user
# useradd gdnsd -s /usr/sbin/nologin

start gdnsd
# gdnsd start
# /usr/local/sbin/gdnsd status
status: running at pid 25498 in pidfile /usr/local/var/run/gdnsd/gdnsd.pid

# lsof -ni:53
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gdnsd   25498 gdnsd    8u  IPv4  41953      0t0  UDP 127.0.0.1:domain
gdnsd   25498 gdnsd    9u  IPv4  41954      0t0  TCP 127.0.0.1:domain (LISTEN)
gdnsd   25498 gdnsd   10u  IPv4  41955      0t0  UDP 192.168.10.237:domain
gdnsd   25498 gdnsd   11u  IPv4  41956      0t0  TCP 192.168.10.237:domain (LISTEN)

gdnsd also listens to TCP 3506 as HTTP
# lsof -ni:3506
COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gdnsd   25498 gdnsd   12u  IPv4  41957      0t0  TCP 127.0.0.1:3506 (LISTEN)
gdnsd   25498 gdnsd   13u  IPv4  41958      0t0  TCP 192.168.10.237:3506 (LISTEN)

# dig @127.1 version.bind chaos txt +norec

; <<>> DiG 9.8.1-P1 <<>> @127.1 version.bind chaos txt +norec
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16597
;; flags: qr; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;version.bind.                  CH      TXT

;; ANSWER SECTION:
version.bind.           0       CH      TXT     "gdnsd"

when accessing to TCP 3506 over HTTP

register a zone file.

make a zone file “foo.com”
# cat /usr/local/etc/gdnsd/zones/foo.com
$ORIGIN foo.com.
$TTL 86400
@     SOA ns1 hostmaster (
       1      ; serial
       7200   ; refresh
       30M    ; retry
       3D     ; expire
       900    ; ncache
)

   NS      ns1
   NS      ns2
ns1 IN A 127.0.0.1
ns2 IN A 127.0.0.2
www IN A 127.0.0.3

You do not need to define the zone in “basic configuration” file.( /usr/local/etc/gdnsd/config)
gdnsd automatically loads zone files under /usr/local/etc/gdnsd/zones directory.
# cat /usr/local/etc/gdnsd/config
options => {
   log_stats => 86400
   tcp_timeout => 15 ; zonefile-style comment
   include_optional_ns => true
   listen => [ 127.0.0.1, 192.168.10.237 ]
   http_listen => [ 127.0.0.1, 192.168.10.237 ]
}

plugins => {
 null => {}
}

# gdnsd checkconf
Loading configuration
DNS listener configured for 127.0.0.1:53
DNS listener configured for 192.168.10.237:53
Loading zone data
rfc1035: quiescence times are 0.01 min, 5 full
rfc1035: will use inotify for zone change detection
Zone foo.com.: source rfc1035:foo.com with serial 1 loaded as authoritative
Configuration and zone data loads just fine

reload gdnsd
# dig @127.1 www.foo.com

# dig @127.1 www.foo.com +norec

; <<>> DiG 9.8.1-P1 <<>> @127.1 www.foo.com +norec
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40085
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;; QUESTION SECTION:
;www.foo.com.                   IN      A

;; ANSWER SECTION:
www.foo.com.            86400   IN      A       127.0.0.3

;; AUTHORITY SECTION:
foo.com.                86400   IN      NS      ns2.foo.com.
foo.com.                86400   IN      NS      ns1.foo.com.

;; ADDITIONAL SECTION:
ns2.foo.com.            86400   IN      A       127.0.0.2
ns1.foo.com.            86400   IN      A       127.0.0.1

add one more zone “bar.com”
# cat /usr/local/etc/gdnsd/zones/bar.com
$ORIGIN bar.com.
$TTL 86400
@     SOA ns1 hostmaster (
       1      ; serial
       7200   ; refresh
       30M    ; retry
       3D     ; expire
       900    ; ncache
)

   NS      ns1
   NS      ns2
ns1 IN A 127.1.0.1
ns2 IN A 127.1.0.2
www IN A 127.1.0.3

# gdnsd checkconf
Loading configuration
DNS listener configured for 127.0.0.1:53
DNS listener configured for 192.168.10.237:53
Loading zone data
rfc1035: quiescence times are 0.01 min, 5 full
rfc1035: will use inotify for zone change detection
Zone bar.com.: source rfc1035:bar.com with serial 1 loaded as authoritative
Zone foo.com.: source rfc1035:foo.com with serial 1 loaded as authoritative
Configuration and zone data loads just fine

# gdnsd reload
SIGHUP sent to daemon instance at pid 25498

# dig @127.1 bar.com ns +norec

; <<>> DiG 9.8.1-P1 <<>> @127.1 bar.com ns +norec
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31556
;; flags: qr aa; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2

;; QUESTION SECTION:
;bar.com.                       IN      NS

;; ANSWER SECTION:
bar.com.                86400   IN      NS      ns2.bar.com.
bar.com.                86400   IN      NS      ns1.bar.com.

;; ADDITIONAL SECTION:
ns2.bar.com.            86400   IN      A       127.1.0.2
ns1.bar.com.            86400   IN      A       127.1.0.1

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.