Skip to content

Commit

Permalink
Attempt to add DDNS support
Browse files Browse the repository at this point in the history
  • Loading branch information
uubk committed Mar 27, 2024
1 parent 3e0200e commit b5d9fc1
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 3 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt update && \
ADD conf/kea-ctrl-agent.conf /etc/kea/kea-ctrl-agent.conf
ADD conf/kea-dhcp4.conf.env /etc/kea/kea-dhcp4.conf.env
ADD conf/kea-dhcp6.conf.env /etc/kea/kea-dhcp6.conf.env
ADD conf/kea-ddns.conf.env /etc/kea/kea-ddns.conf.env
ADD bootstrap.sh /bootstrap.sh

ENTRYPOINT ["/bootstrap.sh"]
3 changes: 3 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ echo "HOSTNAME: ${HOSTNAME}"
# KEA_DB_PASSWORD is not printed
envsubst '$KEA_DB_HOST,$KEA_DB_PORT,$KEA_DB_USER,$KEA_DB_DB,$KEA_DB_PASSWORD,$HOSTNAME' < /etc/kea/kea-dhcp4.conf.env > /etc/kea/kea-dhcp4.conf
envsubst '$KEA_DB_HOST,$KEA_DB_PORT,$KEA_DB_USER,$KEA_DB_DB,$KEA_DB_PASSWORD,$HOSTNAME' < /etc/kea/kea-dhcp6.conf.env > /etc/kea/kea-dhcp6.conf
envsubst '$KEA_DB_HOST,$KEA_DB_PORT,$KEA_DB_USER,$KEA_DB_DB,$KEA_DB_PASSWORD,$HOSTNAME,$DDNS_KEY' < /etc/kea/kea-ddns.conf.env > /etc/kea/kea-ddns.conf

echo "Startmode: $1 $2"

if [ "$1" = "agent" ] ; then
exec /usr/sbin/kea-ctrl-agent -c /etc/kea/kea-ctrl-agent.conf
elif [ "$1" = "dhcpv6" ]; then
exec /usr/sbin/kea-dhcp6 -c /etc/kea/kea-dhcp6.conf
elif [ "$1" = "ddns" ]; then
exec /usr/sbin/kea-dhcp-ddns -c /etc/kea/kea-ddns.conf
else
exec /usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf
fi
6 changes: 3 additions & 3 deletions conf/kea-ctrl-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"dhcp6": {
"socket-type": "unix",
"socket-name": "/run/kea-dhcp6-ctrl-socket"
}
/*"d2": {
},
"d2": {
"socket-type": "unix",
"socket-name": "/tmp/kea-ddns-ctrl-socket"
}*/
}
},

// Specify hooks libraries that are attached to the Control Agent.
Expand Down
119 changes: 119 additions & 0 deletions conf/kea-ddns.conf.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
// ------------------ DHCP-DDNS ---------------------
"DhcpDdns":
{

// -------------- Global Parameters ----------------
// D2 will listen for update requests for Kea DHCP servers at 127.0.0.1
// on port 53001. Maximum time to we will wait for a DNS server to
// respond to us is 1000 ms.

"ip-address": "127.0.0.1",
"port": 53001,
"dns-server-timeout" : 1000,

// One extra feature that requires some explanation is
// user-context. This is a structure that you can define at global scope,
// in ddns domain, dns server, tsig key and others. It is parsed by
// Kea, but not used directly. It is intended to keep anything you
// may want to put there - comments, extra designations, floor or
// department names etc.
// A comment entry is translated into a user-context with a "comment"
// property so you can include comments inside the configuration itself.

"user-context": { "version": 1 },

// ----------------- Control Socket -----------------

"control-socket": {
"socket-type": "unix",
"socket-name": "/run/kea-ddns-ctrl-socket"
},

"forward-ddns":
{
"ddns-domains":
[
{
"comment": "forward domain",
"name": "lan.geco.ethz.ch.",
"key-name": ".key",
"dns-servers":
[
{
"ip-address": "10.233.242.201"
}
]
},
]
},

"reverse-ddns":
{
"ddns-domains":
[
{
"comment": "v4 reverse domain",
"name": "233.10.in-addr.arpa.",
"key-name": "key",
"dns-servers":
[
{
"ip-address": "10.233.242.201"
}
]
},
{
"comment": "v6 reverse domain",
"name": "0.7.c.4.c.e.0.1.c.7.6.0.1.0.0.2.ip6.arpa.",
"key-name": "key",
"dns-servers":
[
{
"ip-address": "10.233.242.201"
}
]
},
]
},

// ------------------ TSIG keys ---------------------
// Each key has a name, an algorithm (HMAC-MD5, HMAC-SHA1, HMAC-SHA224...)
// and a base-64 encoded shared secret.
"tsig-keys":
[
{
"name": "key",
"algorithm": "HMAC-SHA256",
"secret": "$DDNS_KEY"
}
],

// The following configures logging. It assumes that messages with at least
// informational level (info, warn, error and fatal) should be logged to stdout.
// It also specifies a custom log pattern.
"loggers": [
{
"name": "kea-dhcp-ddns",
"output-options": [
{
"output": "stdout",
// Several additional parameters are possible in addition
// to the typical output. Flush determines whether logger
// flushes output to a file. Maxsize determines maximum
// filesize before the file is rotated. maxver
// specifies the maximum number of rotated files being
// kept.
"flush": true,
"maxsize": 204800,
"maxver": 4,
"pattern": "%d [%c/%i] %m\n"
}
],
"debuglevel": 0,
"severity": "INFO"
}
]
}

}

0 comments on commit b5d9fc1

Please sign in to comment.