Skip to content

Instantly share code, notes, and snippets.

@x-drum
Created February 1, 2015 14:36
Show Gist options
  • Save x-drum/ff79d2a2197f1794a2bc to your computer and use it in GitHub Desktop.
Save x-drum/ff79d2a2197f1794a2bc to your computer and use it in GitHub Desktop.
nsupdate (bind9)
cat <<TSTZONE
// file: dynamic.foo.bar.db
$TTL 86400 ; 1 minute
@ IN SOA dynamic.foo.bar. root.foo.bar. (
2001072010 ; serial
10800 ; refresh (3 hours)
3600 ; retry (1 hour)
1814400 ; expire (3 weeks)
86400 ; minimum (1 day)
)
@ NS ns.foo.bar.
hostname 60 IN A 1.2.3.4
TSTZONE
cat <<KEYFILE
// file: dynamic.foo.bar.keys
key "host.dynamic.foo.bar" {
algorithm hmac-md5;
secret "QWERTYUIOPASDFGHJKLZ==";
};
KEYFILE
cat <<CONFLOCAL
// file: name.conf.local
include "/etc/bind/dynamic.foo.bar.keys";
zone "dynamic.foo.bar" {
type master;
file "/etc/bind/dynamic.foo.bar.db";
update-policy {
grant *.dynamic.foo.bar self dynamic.foo.bar.;
};
};
CONFLOCAL
cat <<UPDATE | nsupdate -k /path/to/KEYFILE
server 127.0.0.2
zone dynamic.foo.bar.
update delete hostname.dynamic.foo.bar.
update add hostname.dynamic.foo.bar. 600 A 1.2.3.5
send
UPDATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment