From 8707c06d7a38bd353413078e22a04635b16dc821 Mon Sep 17 00:00:00 2001 From: Mikael Hansson Date: Fri, 15 Jul 2022 12:23:09 +0200 Subject: [PATCH] Initial commit --- README.md | 4 +++ etc/bind/dhcpd.conf | 33 ++++++++++++++++++ etc/bind/named.conf.local | 13 +++++++ etc/dhcp/dhcpd.conf | 38 +++++++++++++++++++++ etc/resolv.conf | 4 +++ etc/systemd/resolved.conf | 4 +++ var/lib/bind/db.200.199.10.in-addr.arpa.rev | 12 +++++++ var/lib/bind/db.mydomain.com | 11 ++++++ 8 files changed, 119 insertions(+) create mode 100644 README.md create mode 100644 etc/bind/dhcpd.conf create mode 100644 etc/bind/named.conf.local create mode 100644 etc/dhcp/dhcpd.conf create mode 100644 etc/resolv.conf create mode 100644 etc/systemd/resolved.conf create mode 100644 var/lib/bind/db.200.199.10.in-addr.arpa.rev create mode 100644 var/lib/bind/db.mydomain.com diff --git a/README.md b/README.md new file mode 100644 index 0000000..c41e06a --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +DNS, DDNS and DHCP on a Linux router +==================================== +This is a complementary repository to my blog post on setting up a more advanced configuration in a simple Linux router, at [https://oxcrag.net/2022/02/12/dns-ddns-and-dhcp-on-a-linux-router/](https://oxcrag.net/2022/02/12/dns-ddns-and-dhcp-on-a-linux-router/). + diff --git a/etc/bind/dhcpd.conf b/etc/bind/dhcpd.conf new file mode 100644 index 0000000..ad7e3df --- /dev/null +++ b/etc/bind/dhcpd.conf @@ -0,0 +1,33 @@ +option domain-name "mydomain.com"; +option domain-name-servers 10.199.200.1; + +default-lease-time 600; +max-lease-time 7200; + +ddns-update-style standard; +update-static-leases on; +authoritative; +key "rndc-key" { + algorithm hmac-sha256; + secret ""; +}; +allow unknown-clients; +use-host-decl-names on; + +zone mydomain.com. { + primary 10.199.200.1; + key rndc-key; +} +zone 200.199.10.in-addr.arpa. { + primary 10.199.200.1; + key rndc-key; +} + +subnet 10.199.200.0 netmask 255.255.255.0 { + range 10.199.200.100 10.199.200.254; + option subnet-mask 255.255.255.0; + option routers 10.199.200.1; + option domain-name "mydomain.com"; + ddns-domainname "mydomain.com."; + ddns-rev-domainname "in-addr.arpa."; +} diff --git a/etc/bind/named.conf.local b/etc/bind/named.conf.local new file mode 100644 index 0000000..5207260 --- /dev/null +++ b/etc/bind/named.conf.local @@ -0,0 +1,13 @@ +zone "mydomain.com" { + type master; + notify yes; + file "/var/lib/bind/db.mydomain.com"; + allow-update { key rndc-key; }; +}; + +zone "200.199.10.in-addr.arpa" IN { + type master; + notify yes; + file "/var/lib/bind/db.200.199.10.in-addr.arpa.rev"; + allow-update { key rndc-key; }; +}; diff --git a/etc/dhcp/dhcpd.conf b/etc/dhcp/dhcpd.conf new file mode 100644 index 0000000..22e9a04 --- /dev/null +++ b/etc/dhcp/dhcpd.conf @@ -0,0 +1,38 @@ +option domain-name "mydomain.com"; +option domain-name-servers 10.199.200.1; + +default-lease-time 600; +max-lease-time 7200; + +ddns-update-style standard; +update-static-leases on; +authoritative; +key "rndc-key" { + algorithm hmac-sha256; + secret ""; +}; +allow unknown-clients; +use-host-decl-names on; + +zone mydomain.com. { + primary 10.199.200.1; + key rndc-key; +} +zone 200.199.10.in-addr.arpa. { + primary 10.199.200.1; + key rndc-key; +} + +subnet 10.199.200.0 netmask 255.255.255.0 { + range 10.199.200.100 10.199.200.254; + option subnet-mask 255.255.255.0; + option routers 10.199.200.1; + option domain-name "mydomain.com"; + ddns-domainname "mydomain.com."; + ddns-rev-domainname "in-addr.arpa."; +} + +host example { + hardware ethernet 52:54:00:de:ad:af; + fixed-address 10.199.200.27; +} diff --git a/etc/resolv.conf b/etc/resolv.conf new file mode 100644 index 0000000..03098b3 --- /dev/null +++ b/etc/resolv.conf @@ -0,0 +1,4 @@ +nameserver 10.199.200.1 +nameserver 1.1.1.1 +nameserver 1.0.0.1 +search mydomain.com diff --git a/etc/systemd/resolved.conf b/etc/systemd/resolved.conf new file mode 100644 index 0000000..7a6e5a1 --- /dev/null +++ b/etc/systemd/resolved.conf @@ -0,0 +1,4 @@ + +[Resolve] +DNS=10.199.200.1,10.199.200.20 +Domains=mydomain.com diff --git a/var/lib/bind/db.200.199.10.in-addr.arpa.rev b/var/lib/bind/db.200.199.10.in-addr.arpa.rev new file mode 100644 index 0000000..84abd42 --- /dev/null +++ b/var/lib/bind/db.200.199.10.in-addr.arpa.rev @@ -0,0 +1,12 @@ +$ORIGIN . +$TTL 3600 ; 1 hour +200.199.10.in-addr.arpa IN SOA gateway.mydomain.com. ( + 1000 ; serial + 14400 ; refresh (4 hours) + 3600 ; retry (1 hour) + 604800 ; expire (1 week) + 300 ; minimum (5 minutes) + ) + NS gateway.mydomain.com. +$ORIGIN 200.199.10.in-addr.arpa. +1 PTR gateway.mydomain.com. diff --git a/var/lib/bind/db.mydomain.com b/var/lib/bind/db.mydomain.com new file mode 100644 index 0000000..11755fb --- /dev/null +++ b/var/lib/bind/db.mydomain.com @@ -0,0 +1,11 @@ +$ORIGIN . +$TTL 604800 ; 1 week +mydomain.com IN SOA gateway.mydomain.com. ( + 1000 ; serial + 14400 ; refresh (4 hours) + 3600 ; retry (1 hour) + 604800 ; expire (1 week) + 300 ; minimum (5 minutes) + ) + NS gateway.mydomain.com. +gateway A 10.199.200.1