Skip to content

Commit ffc582f

Browse files
authored
feat: make all per-site settings configurable via .env file and unbound.d/ files (#8)
Also switched my local Unifi DNS to a more generic domain names: .lan, .mgmt.lan and .iot.lan The one site-specific are the IP CIDR which are what my LAN uses: several 10.0.NN.1/24 ranges.
1 parent 1fa9c1c commit ffc582f

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"servfail",
2121
"setpassword",
2222
"stripprefix",
23+
"toplevel",
2324
"traefik",
2425
"Ubiquiti"
2526
],

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dig -p 5300 @localhost cloudflare.com +dnssec
3434
directly connect to container:
3535

3636
```bash
37-
docker exec -it dns sh
37+
docker exec -it dns ash
3838
```
3939

4040
## Deployment
@@ -43,10 +43,12 @@ docker exec -it dns sh
4343

4444
- git clone this repo (or [download main branch as zip, then unzip](https://github.com/davidjenni/pi-hole-unbound/archive/refs/heads/main.zip))
4545
- Create your own *.prod.env file, use the checked in jenni.prod.env as starting point
46-
- start compose stack:
46+
- re-start compose stack (build & pull before stopping the already running DNS server!):
4747

4848
```bash
49-
docker compose --env-file your.prod.env up -d
49+
docker compose --env-file lan.prod.env build --pull && \
50+
docker compose --env-file lan.prod.env stop && \
51+
docker compose --env-file lan.prod.env up -d --wait && \
5052
docker compose ps
5153
```
5254

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ services:
6565
FTLCONF_dns_dnssec: "true"
6666
FTLCONF_dns_interface: "eth0"
6767
FTLCONF_dns_listeningMode: "BIND"
68-
FTLCONF_dns_revServers: "PIHOLE_LOCAL_DNS_REVERSE_SERVERS"
68+
FTLCONF_dns_revServers: "$PIHOLE_LOCAL_DNS_REVERSE_SERVERS"
6969
FTLCONF_dns_reply_host_force4: "true"
7070
FTLCONF_webserver_paths_prefix: "/pihole"
7171
# set webUI password later via:
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# production .env settings for my local network: jenni.mgmt
1+
# production .env settings for my local network: .lan, .iot.lan, .mgmt.lan
2+
# the LAN specific address ranges and VLANS work for my local setup
23
#
34
# launch with:
4-
# docker compose --env-file jenni.prod.env up -d
5+
# docker compose --env-file lan.prod.env up -d
56

7+
PIHOLE_INSTANCE_NAME=pi-docker0
68
PIHOLE_DNS_PORT=53
7-
PIHOLE_HOSTNAME=ns1.jenni.mgmt
9+
PIHOLE_HOSTNAME=${PIHOLE_INSTANCE_NAME}.mgmt.lan
810

911
# https://docs.pi-hole.net/docker/configuration/?h=tz#environment-variables
1012
PIHOLE_TIMEZONE=America/Los_Angeles
@@ -14,4 +16,5 @@ PIHOLE_TIMEZONE=America/Los_Angeles
1416
# https://github.com/pi-hole/FTL/blob/bc185680fc2af2f7e21bd120f56749051207914f/src/config/validator.c#L366
1517
# // Each entry has to be of form "<enabled>,<ip-address>[/<prefix-len>],<server>[#<port>][,<domain>"]
1618
# The generated pihole.toml also does have a more in depth description of the format.
17-
PIHOLE_LOCAL_DNS_REVERSE_SERVERS=[true,10.0.10.0/24,10.0.10.1,jenni.mgmt]
19+
# For a list of servers, separate each entry with a semicolon `;`
20+
PIHOLE_LOCAL_DNS_REVERSE_SERVERS=true,10.0.10.0/24,10.0.10.1,lan;true,10.0.90.0/24,10.0.10.1,mgmt.lan;true,10.0.30.0/24,10.0.10.1,iot.lan

unbound/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM alpine:latest
22

33
COPY unbound.conf /etc/unbound/unbound.conf
4+
COPY unbound.d/*.conf /etc/unbound/unbound.d/
45
COPY startup.sh /etc/unbound/startup.sh
56

67
RUN apk add --no-cache drill unbound \

unbound/unbound.conf

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ server:
44
interface: 0.0.0.0
55
port: 5335
66
do-ip4: yes
7+
do-ip6: yes
78
prefer-ip4: yes
8-
do-ip6: no
99
do-udp: yes
1010
do-tcp: yes
1111

@@ -37,7 +37,7 @@ server:
3737
# Level 1: Gives operational information.
3838
# Level 2: Gives detailed operational information including short information per query.
3939
# Level 3: Gives query level information, output per query.
40-
# Level 4: Gives algorithm level information.
40+
# Level 4: Gives algorithm level information.
4141
# Level 5: Logs client identification for cache misses.
4242
verbosity: 1
4343
use-syslog: no
@@ -46,18 +46,12 @@ server:
4646
log-servfail: yes
4747
# log-queries: yes
4848
# log-replies: yes
49-
50-
# link to local DNS and local domain:
51-
private-domain: "jenni"
52-
# local domain also doesn't participate in DNSSEC validation
53-
domain-insecure: "jenni"
54-
55-
forward-zone:
56-
name: "jenni"
57-
forward-addr: 10.0.10.1
49+
# log-local-actions: yes
5850

5951
# remote control via unbound-control
6052
remote-control:
6153
control-enable: yes
6254
control-interface: 127.0.0.1
6355
control-use-cert: no
56+
57+
include: "/etc/unbound/unbound.d/*.conf"

unbound/unbound.d/lan.local.conf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# see details in https://www.nlnetlabs.nl/documentation/unbound/unbound.conf/
2+
3+
server:
4+
# link to local DNS and local domain:
5+
private-domain: "lan"
6+
# local domain also doesn't participate in DNSSEC validation
7+
domain-insecure: "lan"
8+
9+
forward-zone:
10+
name: "lan"
11+
forward-addr: 10.0.10.1

0 commit comments

Comments
 (0)