Difference between revisions of "Bind"

From YobiWiki
Jump to navigation Jump to search
m
Line 25: Line 25:
 
<br>and add a hook into ns0.foo.org:/etc/bind/named.conf:
 
<br>and add a hook into ns0.foo.org:/etc/bind/named.conf:
 
include "/etc/bind/dynaname.conf"
 
include "/etc/bind/dynaname.conf"
I needed to set an absolute path to the file, so in dynaname.conf change
 
file "dyn/dyn.bar.org";
 
to
 
file "/var/lib/bind/dyn/dyn.bar.org";
 
   
 
For info dynaname.conf should now look like:
 
For info dynaname.conf should now look like:
 
<pre>
 
<pre>
 
key home.dyn.bar.org {
 
key home.dyn.bar.org {
algorithm HMAC-MD5;
+
algorithm HMAC-SHA512;
 
secret "some secret...";
 
secret "some secret...";
 
};
 
};
Line 39: Line 35:
 
zone "dyn.bar.org" in {
 
zone "dyn.bar.org" in {
 
type master;
 
type master;
file "/var/lib/bind/dyn/dyn.bar.org";
+
file "dyn/dyn.bar.org";
 
update-policy {
 
update-policy {
 
grant home.dyn.bar.org name home.dyn.bar.org A AAAA TXT;
 
grant home.dyn.bar.org name home.dyn.bar.org A AAAA TXT;
Line 45: Line 41:
 
};
 
};
 
</pre>
 
</pre>
Create ns0.foo.org:/var/lib/bind/dyn
 
   
Create ns0.foo.org:/var/lib/bind/dyn/dyn.bar.org
+
Create ns0.foo.org:/var/cache/bind/dyn/dyn.bar.org with the following content:
 
Content of ns0.foo.org:/var/lib/bind/dyn/dyn.bar.org
 
 
<pre>
 
<pre>
 
$ORIGIN .
 
$ORIGIN .
Line 65: Line 58:
   
 
Make sure bind has RW access:
 
Make sure bind has RW access:
root@ns0:/var/lib/bind/dyn# ls -al
+
root@ns0:/var/cache/bind/dyn# ls -al
 
total 16
 
total 16
 
drwxrwxr-x 2 root bind 4096 Jun 3 23:44 .
 
drwxrwxr-x 2 root bind 4096 Jun 3 23:44 .
Line 73: Line 66:
 
Reload bind
 
Reload bind
 
/etc/init.d/bind9 reload
 
/etc/init.d/bind9 reload
  +
  +
Check messages
  +
tail /var/log/syslog
  +
 
==Update from client==
 
==Update from client==
 
./dynaname -H home.dyn.bar.org -S ns0.foo.org -A 1.2.3.4
 
./dynaname -H home.dyn.bar.org -S ns0.foo.org -A 1.2.3.4

Revision as of 21:20, 4 June 2014

Intro

Some notes how to setup a dynamic DNS...
Setup is based on Askarel's dynaname
Thank you Fred for the help!

Requirements

Your DNS server

apt-get install bind9

This will be the nameserver ns0.foo.org for our dynamic subdomain dyn.bar.org so this has to be announced in the primary DNS of your bar.org domain:

dyn    NS    ns0.foo.org.

To test it:

dig @your.primary.dns.for.bar.org dyn.bar.org
;; AUTHORITY SECTION:
dyn.bar.org.        10800    IN    NS    ns0.foo.org.

Your dynamic IP client

apt-get install dnsutils bind9utils
git clone https://github.com/askarel/dynaname.git

Setup on client

To create e.g. home.dyn.bar.org:

cd dynaname
./dynaname -G -H home.dyn.bar.org -S ns0.foo.org

Setup on server

Copy client ns0.foo.org/etc/bind/dynaname.conf to ns0.foo.org:/etc/bind/
and add a hook into ns0.foo.org:/etc/bind/named.conf:

include "/etc/bind/dynaname.conf"

For info dynaname.conf should now look like:

key home.dyn.bar.org {
        algorithm HMAC-SHA512;
        secret "some secret...";
};

zone "dyn.bar.org" in {
        type master;
        file "dyn/dyn.bar.org";
        update-policy {
                grant home.dyn.bar.org name home.dyn.bar.org A AAAA TXT;
        };
};

Create ns0.foo.org:/var/cache/bind/dyn/dyn.bar.org with the following content:

$ORIGIN .
$TTL 3600    ; 1 hour
dyn.bar.org.      IN SOA    ns0.foo.org. me.bar.org. (
                  2014060301 ; serial, increment it every time you edit file
                  600        ; refresh (10 minutes)
                  300        ; retry (5 minutes)
                  86400      ; expire (1 day)
                  300        ; minimum (5 minutes)
                  )
dyn.bar.org.      IN NS     ns0.foo.org.
$ORIGIN dyn.bar.org.

Make sure bind has RW access:

root@ns0:/var/cache/bind/dyn# ls -al
total 16
drwxrwxr-x 2 root bind 4096 Jun  3 23:44 .
drwxrwxr-x 3 root bind 4096 Jun  3 23:15 ..
-rw-r--r-- 1 bind bind  389 Jun  3 23:44 dyn.bar.org

Reload bind

/etc/init.d/bind9 reload

Check messages

tail /var/log/syslog

Update from client

./dynaname -H home.dyn.bar.org -S ns0.foo.org -A 1.2.3.4