Linux/DDNS

From Omnia
Jump to navigation Jump to search

DDNS

BigDinosaur Blog - https://blog.bigdinosaur.org/running-bind9-and-isc-dhcp/

Dependencies

# centos 6.5
yum install bind dhcp
# generate /etc/rndc.key 
/usr/sbin/rndc-confgen -a
# sample /etc/rndc.key
key "rndc-key" {
        algorithm hmac-md5;
        secret "xxxxxxxxxxzk9EdYZ9SP8Q==";
};

Bind

/etc/named.conf

include "/etc/rndc.key";

#key "rndc-key" {
#        algorithm hmac-md5;
#        secret "xxxxxxxxxxzk9EdYZ9SP8Q==";
#};

zone "lab" {
    type master;
    file "/var/named/db.lab";
    allow-update { key rndc-key; };
};

zone "200.100.10.in-addr.arpa" {
    type master;
    file "/var/named/200.100.10.rev";
    allow-update { key rndc-key; };
};

/var/named/db.lab:

$ORIGIN .
$TTL 10 ; 10 seconds
lab                     IN SOA  ns1.lab. hostmaster.lab. (
                                2014080111 ; serial
                                120        ; refresh (2 minutes)
                                120        ; retry (2 minutes)
                                2419200    ; expire (4 weeks)
                                120        ; minimum (2 minutes)
                                )
                        NS      ns1.lab.
$ORIGIN lab.
$TTL 30 ; 30 seconds
master                  A       10.100.200.3
ns1                     A       10.100.200.3
chmod g+w /var/named
chmod g+w /var/named/db.lab
chown :named /var/named/db.lab

DHCPd

/etc/dhcp/dhcpd.conf

authoritative;
option domain-name "lab";
option domain-search "lab", "example.com";
option domain-name-servers 10.100.200.3;
#option domain-name-servers 10.100.1.1, 10.100.2.1;

ddns-updates            on;
ddns-update-style       interim;
update-static-leases    on;
#ignore                  client-updates;

#key rndc-key { algorithm hmac-md5; secret xxxxxxxxxxzk9EdYZ9SP8Q==;}
include "/etc/rndc.key";

allow unknown-clients;
use-host-decl-names on;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

zone lab. {
        primary localhost;
        key rndc-key;
}
zone 200.100.10.in-addr.arpa. {
        primary localhost;
        key rndc-key;
}


subnet 10.100.200.0 netmask 255.255.255.0 {
  range 10.100.200.100 10.100.200.254;
  option subnet-mask 255.255.255.0;
  option routers 10.100.200.1;
  option broadcast-address 10.100.200.255;
  ddns-domainname "lab.";
  ddns-rev-domainname "in-addr.arpa.";

  ## PXE stuff unrelated...
  #if exists user-class and option user-class = "iPXE" {
  #  filename "bootstrap.ipxe";
  #} else {
  #  filename "undionly.kpxe";
  #}
  #next-server 10.100.200.3;
}


Services

Config check:

named-checkconf

Restart services:

service named restart
service dhcpd restart