feat: adguard home + powerdns plz (#100)

* hack

* feat: adguard + powerdns

---------

Co-authored-by: Truxnell <9149206+truxnell@users.noreply.github.com>
This commit is contained in:
Truxnell 2024-04-16 22:59:57 +10:00 committed by GitHub
parent ab986343e1
commit 0dffbe9433
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 309 additions and 50 deletions

View file

@ -10,6 +10,8 @@
Leveraging nix, nix-os and other funny magic man words to apply machine and home configurations
[Repository Documentation](https://truxnell.github.io/nix-config/)
## Background
Having used a variety of infracture as code solutions - and having found them lacking in some areas, it is time to give nix a go.

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 KiB

6
docs/monitoring/zed.md Normal file
View file

@ -0,0 +1,6 @@
Zed monitoring can also send to pushover!
<figure markdown="span">
![Alt text](../includes/assets/zed_alert.png)
<figcaption>Come on these drives are hardly 12months old</figcaption>
</figure>

View file

@ -11,7 +11,7 @@ Code TLDR
:simple-github:[/nixos/modules/nixos/system/motd](https://github.com/truxnell/nix-config/blob/462144babe7e7b2a49a985afe87c4b2f1fa8c3f9/nixos/modules/nixos/system/motd/default.nix])
Write a shell script using nix with a bash motd
Write a shell script using nix with a bash motd of your choosing.
```nix
let

View file

@ -14,12 +14,21 @@
mySystem.services = {
openssh.enable = true;
maddy.enable = true;
dnscrypt-proxy.enable = true;
cfDdns.enable = true;
bind.enable = true;
powerdns = {
enable = true;
admin-ui = false;
};
adguardhome.enable = true;
};
# no mutable state I care about
mySystem.system.resticBackup =
{
local.enable = false;
remote.enable = false;
};
networking.hostName = "dns01"; # Define your hostname.
networking.useDHCP = lib.mkDefault true;

View file

@ -14,10 +14,21 @@
mySystem.services = {
openssh.enable = true;
dnscrypt-proxy.enable = true;
cfDdns.enable = true;
bind.enable = true;
powerdns = {
enable = true;
admin-ui = false;
};
adguardhome.enable = true;
};
# no mutable state I care about
mySystem.system.resticBackup =
{
local.enable = false;
remote.enable = false;
};
networking.hostName = "dns02"; # Define your hostname.
networking.useDHCP = lib.mkDefault true;

View file

@ -14,7 +14,7 @@
gatus.enable = true;
homepage.enable = true;
backrest.enable = true;
# backrest.enable = true;
plex.enable = true;
tautulli.enable = true;
@ -22,6 +22,7 @@
};
mySystem.system.systemd.pushover-alerts.enable = false;
mySystem.nfs.nas.enable = true;
mySystem.persistentFolder = "/persistent";

View file

@ -0,0 +1,90 @@
{ lib
, config
, pkgs
, ...
}:
with lib;
let
cfg = config.mySystem.services.adguardhome;
port = 53;
port_webui = 3000;
in
{
options.mySystem.services.adguardhome = {
enable = mkEnableOption "Adguard Home";
openFirewall = mkEnableOption "Open firewall for ${app}" // {
default = true;
};
};
config = mkIf cfg.enable {
services.adguardhome = {
enable = true;
mutableSettings = false;
settings = {
bind_host = "0.0.0.0";
bind_port = port_webui;
auth_attempts = 3;
block_auth_min = 3600;
dns = {
bind_host = "127.0.0.1";
port = port;
upstream_dns = [
"https://dns10.quad9.net/dns-query"
"https://doh.mullvad.net/dns-query"
];
fallback_dns = [ "https://dns.cloudflare.com/dns-query" ];
bootstrap_dns = [
# quad9
"9.9.9.10"
"149.112.112.10"
"2620:fe::10"
"2620:fe::fe:10"
# cloudflare
"1.1.1.1"
"2606:4700:4700::1111"
];
upstream_mode = "load_balance";
cache_size = 4194304;
cache_ttl_min = 60;
cache_optimistic = true;
use_private_ptr_resolvers = true;
local_ptr_upstreams = [ "localhost:5353" ];
rewrites = [{
domain = "*.${config.networking.domain}";
answer = "10.8.10.1"; # UDMP router
}];
filters = [
{
name = "AdGuard DNS filter";
url = "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt";
enabled = true;
}
{
name = "AdAway Default Blocklist";
url = "https://adaway.org/hosts.txt";
enabled = true;
}
{
name = "OISD (Big)";
url = "https://big.oisd.nl";
enabled = true;
}
];
};
};
};
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ port port_webui ];
allowedUDPPorts = [ port port_webui ];
};
};
}

View file

@ -88,19 +88,14 @@ in
10.5.0.0/24; # CONTAINERS
};
key "tsig-key" {
algorithm hmac-sha512;
secret "iZhi4kaPJBvqxyW73aKYRnNy5e7N2A+7WczxAMcCvDl8QpAc0HFjfI1Q+0g1SBUQBZXqAvGFViegPsK9lZ3bkA==";
};
zone "trux.dev." {
type master;
file "${config.sops.secrets."system/networking/bind/trux.dev".path}";
allow-transfer {
tsig-key;
};
update-policy {
grant tsig-key zonesub ANY;
};
allow-query { any; };

View file

@ -1,8 +1,9 @@
system:
networking:
bind:
trux.dev: ENC[AES256_GCM,data:+4mZg26mT4V0+ugHOyhuXUl+WdpBju+Nd222jDKMZBQzIrw1ab9J3yBd5X55yT57sdm10AMh78qg/tvoOjMjFSjnU7ftyoTmT4IaKJ64feFX01v02iaH3Qs5WS18qDpQ3WcY2qe2UlACe35jhEzC9jXn+dHM5evwkkVou+BfTbFOTaqmAJnZ4d2q1vzxMQFjTEUm8z5no5c2wOacQJ6zZUQC0q80kLsfuh+dlrMyC6Pb8gpxkvWxGNZM3JkpjA0QOlMhmANAAC5Jo34Cr2tdaM/P2yeo8iiM6UAbBdzX49fc9TBSByQN2NALG5tEpW4/SEBkUAAo2NKXPaWcsQLiQxNFfEPtRKFKeADtc88SE65YsDwr9dtt09YV/0cPoUOo7fI0YLqtdMLKkljYKRTI1hyeyAcZ5uMPfcAcKRs7r+REWn6PRueAF3ncP6aSYEgLUTft3qkrfeJRB/yWtrW/ixQ/0/C66Rm2DQOpZGyVBx7PBUkMb2r9SHRJa/sTpjDTt18/En36qIkhuJjjnTJ93GO1WnnSo3rlUmWVHKBon8Bwegr53qc/j3tEePs1jzwcVDkaRZpiNPG7DVTzC7Z1pY9HiAPNTDR90Odb8WBZGIbm2vuX8ZKOVhbGyX0KJn2x4Z0bgRIAAub8gTn3nvYa0QM0IWM3RhPa3Bng9Q3rCU7TT2k4584sMlz+n3TwARM4k2lR9tuS4g73UpqYX7zzN3tjRdyzaX43R3PtIv3fVES5bStoYssVqih6k6nqwU/osUIgFsag8qC17//d2WNiEltewm5aPEFI3uPT9HIU1ItklU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66Qrxlg88K/Gb
MT1h2v6h5uiYm6JaspSqz9Hqx9YfRocl/kJmVy/QdeIGPVzm24dnIQ==
-----END AGE ENCRYPTED FILE-----
- recipient: age1u4tht685sqg6dkmjyer96r93pl425u6353md6fphpd84jh3jwcusvm7mgk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBxVVJTZjV1bVpPemtPSjRO
ZHRDRHBraXk5YXV6SDB0QVY1bXIvSnBQRjM4Cms3aWdrQ2NyelB0ODMxclI0ai9v
dWVGUThkV2kvOGlQdXI1bjBPRC9uVFEKLS0tIFRDVGhZRWx2NEhFcHJ4U0lJRlky
QXMwK1pkSTAwYWZnREY3OEx3TU0yamcKHAr9joyZgv8w1QXdIjgsBtwEE75nil2P
HSQ0LRfRln71JMarqaCvrX3HjCi94yT5+toT+MOor7kovb+o4GEwcQ==
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB1Sy85ZVA3WGVhVWlSZmhy
VDBDK2dZYmR6djlQYkhhQ25zeWdxM1JpMEg0Ck5hZm12ZmtkQmJLUmdMNm94WnZL
NnY1eG1neEpLSEVkRGhkY2FHUFhTWVkKLS0tIGVpNlZrRGtqRFR1OVc3enpRUVQ2
N2swa1BIellpbjBUbmsyc2NnYmphOU0Kx/4I/zjyi3GlYMgcNIb7sYufLfvJ9Xny
HeR7r03YuHu5dOQ1T8iFigXUhy/2DkdW8kWtKlpuT0qg35dKqjCi/w==
-----END AGE ENCRYPTED FILE-----
- recipient: age1cp6vegrmqfkuj8nmt2u3z0sur7n0f7e9x9zmdv4zygp8j2pnucpsdkgagc
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBBZ0ZaY1dEUlhCNzRiMFNu
dkRyWGRoTzFJblNHV2trVkdsMVhlMlNzMFYwCkhZUmJRdjAwZTFhcCtlV1hKUE5u
RzUx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BDTENq
QkNFMTc3VTU1SkxtK0x3SnFzYm90aTgKLS0tIHJHc3NXekM4Ly9SSEFydFZrTk9l
MVUxcEpUemlmWmRvQThUdTdkQ2svNHcK0WyOuWbv+eyYWLFsKBl+K+/n9QCfehqQ
0hC0SY2Nf+9YHMDXrSse44NPs/ucOPlYRFV/HbPNvfEF62K7Gt79lA==
-----END AGE ENCRYPTED FILE-----
- recipient: age1jpeh4s553taxkyxhzlshzqjfrtvmmp5lw0hmpgn3mdnmgzku332qe082dl
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkQVJmTWxzSzNDT1d1NzFX
UnFFbHF6YkVjUmRYTm5VVkhRbXF1SzJuT1NvCmROeFRQNkJpNkE2UWVYeW45b0Zt
dW9Ld3NVend5cEdyN20rV3EzczdHK2MKLS0tIGJYK041RVBBN0IzMC9KRUY1UFNk
REM3YnFBaGY1ejRQeldlc0JJSW5aWjQK3ZYIRxiLOx88kimDGq8GoDMVNbpLvOPz
EVtii9SHQWk4lTVqyqo2WAIc/2PMM8P7Je9xgc/sigR1i8rLQlAyTg==
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB3SHFQQUIzQXlqZFFnTWNt
YVJIb0MzTFM2NENpNFFiaHFmaU95K3VLNGdZCkFyMEFHZjhZclJMTE4yRWNJQnJR
T25yTWZQOFE5L011M3FnMUxPb3hPbVEKLS0tIElzYlpHUEQwejlDNTFmK3R1dU0r
RzJ5UGIvUUluZXNzRzlXRWl5aGdmaUUKObqo2Wj62ZcK0qMcsttRHphWTgkPOTz4
NkvAvOaSX2wJHRhH9SHGhkPwEhsgdmaagsVpwpLPrOCRlWI/bd1Qhg==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-04-15T06:36:15Z"
mac: ENC[AES256_GCM,data:cIXRUz3h2+PCdp0HLs1WjKPQOeGqgxpKfEXflMMUkX5GspOsrDZZYTF2A6bALaGqWAoqvHp5kxN8exTyl8fGM4x1i/eXQiZmTq/DICfCR890buSWAf83bP3X5+H1FJwR9NX37HZlmFVNWxnrKq4DTkC5Yn750LDd9aMls4EjkWA=,iv:ZDF4tgnUE6sfB7NaCouH3jd5IA5fZhZA9++jgBhg3A8=,tag:7gO7vrpkC+EI6ERjFUSy0A==,type:str]
lastmodified: "2024-04-16T06:30:13Z"
mac: ENC[AES256_GCM,data:PsD5hu5nyjPY9/bgLTiTReqoT+hwlJx8A5pOkCTcPNQs63So4GM5mDDTuWG8u1WlBOEdKEDqVefVMtCiwOsC6xIVM8AHCGOcad2j4qQbHR+2lc8nMZE8R7ceJc2ZeLBPlD5/BQ2R5XiQ+NXu0qypHjYkVwnkI62nPSXALSd9btg=,iv:cy7slD5dcfTEeObWraswcghwhgAe1RylU4aafXezEYU=,tag:/nSCQJDYfrWpfpfdkigV7w==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1

View file

@ -14,5 +14,7 @@
./glances
./syncthing
./restic
./powerdns
./adguardhome
];
}

View file

@ -6,16 +6,86 @@
with lib;
let
cfg = config.mySystem.services.powerdns;
persistentFolder = "${config.mySystem.persistentFolder}/nixos/pdns";
user = "pdns";
group = "pdns";
configDir = pkgs.writeTextDir "pdns.conf" "${pdnsConfig}";
# $APIKEY is replaced via envsubst in the pdns module
pdnsConfig = ''
expand-alias=yes
resolver=9.9.9.9:53
local-address=0.0.0.0:5353
launch=gsqlite3
gsqlite3-database=${persistentFolder}/pdns.sqlite3
webserver=yes
webserver-address=0.0.0.0:8081
webserver-allow-from=10.8.10.0/20
api=yes
api-key=$APIKEY
'';
in
{
options.mySystem.services.powerdns.enable = mkEnableOption "powerdns";
options.mySystem.services.powerdns =
{
enable = mkEnableOption "powerdns";
openFirewall = mkEnableOption "Open firewall for ${app}" // {
default = true;
};
admin-ui = mkEnableOption "Powerdns-admin UI";
};
config = mkIf cfg.enable {
# ensure folder exist and has correct owner/group
systemd.tmpfiles.rules = [
"d ${persistentFolder} 0755 ${user} ${group} -" #The - disables automatic cleanup, so the file wont be removed after a period
];
services.powerdns = {
enable = true;
extraConfig = pdnsConfig;
secretFile = config.sops.secrets."system/services/powerdns/apiKey".path;
};
sops.secrets."system/services/powerdns/apiKey" = {
sopsFile = ./secrets.sops.yaml;
restartUnits = [ "pdns.service" ];
};
# powerdns doesnt create the sqlite database for us
# so we gotta either do it manually once-off or do the below to ensure its created
# if the file is missing before service start
systemd.services.pdns.serviceConfig.ExecStartPre = lib.mkBefore [
(pkgs.writeScript "pdns-sqlite-init.sh"
''
#!${pkgs.bash}/bin/bash
pdns_folder="${persistentFolder}"
echo "INIT: Checking if pdns sqlite exists"
# Check if the pdns.sqlite3 file exists in the pdns folder
if [ ! -f "${persistentFolder}/pdns.sqlite3" ]; then
echo "INIT: No sqlite db found, initializing from pdns github schema..."
${pkgs.wget}/bin/wget -O "${persistentFolder}/schema.sqlite3.sql" https://raw.githubusercontent.com/PowerDNS/pdns/master/modules/gsqlite3backend/schema.sqlite3.sql
${pkgs.sqlite}/bin/sqlite3 "${persistentFolder}/pdns.sqlite3" < "${persistentFolder}/schema.sqlite3.sql"
${pkgs.busybox}/bin/chown pdns:pdns ${persistentFolder}/pdns.sqlite3
${pkgs.busybox}/bin/rm "${persistentFolder}/schema.sqlite3.sql"
fi
# Exit successfully
exit 0
''
)
];
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 8081 5353 ];
allowedUDPPorts = [ 8081 5353 ];
};
};
}

View file

@ -0,0 +1,69 @@
system:
services:
powerdns:
apiKey: ENC[AES256_GCM,data:JaOeUekiyKPum0v18Eundtee1UEG2cRjRU4GNQbAZQ==,iv:bSWeb7aIMIKcK1bbqDES85pjdF6X/fUYodsS2CcMo+s=,tag:35/FQRAN9SHe7a0CORFJzw==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1lj5vmr02qkudvv2xedfj5tq8x93gllgpr6tzylwdlt7lud4tfv5qfqsd5u
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSByUHV3Y2RXblFhOEZCUkxZ
bW1VS29LdjBMaWlGdkJoMjVQcTYwR1dWdkhVCnQweW1zYmpGM2dlelN5UHNkSW4z
SzVPeEVVeUk4Z3FBekJjZEdzN0RxOVkKLS0tIGpUTzlHb1BNbC9ubGpsZW4yaVBP
NXFYK0xocE95eW9yeDBCTy9mZEpKZHcKW2Ih9qfT4uIin+R4x8Qz2RFTmD7Oka0z
y8+QoJJh1tLlndUCXqmvgdUf+8ZnUa/AgWqq1g9qxQNg3tng0gi11A==
-----END AGE ENCRYPTED FILE-----
- recipient: age17edew3aahg3t5nte5g0a505sn96vnj8g8gqse8q06ccrrn2n3uysyshu2c
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA4TnNlRGpJMVhhQUF4ZEJM
WmdsSGgrN0hzNGk4dkZNa01pS2crN2tNN21RCjArcHZnUE1vb3FDL0dOaXBDMkNV
NlBId21KTnlGVEJWVENnYi8xRVNkbDQKLS0tIDl3dEpkNDNDNy9tNEhCR3RuSUtl
SWM0Z1BqNzh5RFlRdFNIeVhGTUcvQWsKO9OrohKpjgXdaJZ91REZREv/3iYxaWcV
xPXPl702ionxmgBYz6PIYqLI7vIPaAoUhoGk9f5NSlh2f/aqJBxKbA==
-----END AGE ENCRYPTED FILE-----
- recipient: age1u4tht685sqg6dkmjyer96r93pl425u6353md6fphpd84jh3jwcusvm7mgk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBUa3djcTNhQTFUTHR5VGxM
T1VTVVdGMjdjcC9KSEYxQ3Q4NlZ3VE4zY21nCnFhSmJzSXkyV0NGcjFyNFRsMVha
VEZubXVBWGhMS2U3bFB4N2RETzFmUjQKLS0tIGRrQXZKNjdvN1dxMW5VUFVhb1Rs
cTJROVhkUDExdHBKNi9SYm1vSGhGYW8K3QBsU3XKJrXaTU/hq5PJYaA23SBjWYSZ
yy6zxLp2JB3Hr45GhL9D6Nv+eLyO1grasQEOGNVXnHJC+b/iFqbBYw==
-----END AGE ENCRYPTED FILE-----
- recipient: age1cp6vegrmqfkuj8nmt2u3z0sur7n0f7e9x9zmdv4zygp8j2pnucpsdkgagc
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2M1UrVU9LT1BQOFpsdjkr
NHZYM0JrY3Q4cHhER1haZVJtUjU0OVNkM1dJCmlsRHBHYm4xMHBrUzF1b044NzRv
VnpHQmFPNzg2ZU5tV01HZjRBM0Y1RVUKLS0tIHJVK2VOeEgrMFpDK1R5YmR5TEpp
MmxzMlhxeWhqdHNVN0Q1czFlcm5vR0UKHZuB0sllhE3oFPwhQ/S8vgQoy5siszvj
vJ0eYAWtRh9CCwI1Mmzz7378Bsz1ukC06Q+ClqKRlvqT11y6djBGCg==
-----END AGE ENCRYPTED FILE-----
- recipient: age1j2r8mypw44uvqhfs53424h6fu2rkr5m7asl7rl3zn3xzva9m3dcqpa97gw
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAyY2VjeUx1bzFuZzhTbkFZ
YnhWNE9hV0kraWV5SnVYaFZxRmlBTWNQSGc4CkRaUU90SXQxWk1oMk5KN3Rqd1Q1
NDA2empEbXdvU3dyRWpWSSsvM05mcFUKLS0tIENabFJkd2ZjUFR1M2E1R1RZblhO
N042ZUkyek1JR1p5aWo5YnMwMUhaZ3MKMYK57X47Orwb0/wO8L3wZOR2QHXcN+Yu
FoJugwYJVOw9r0aTnpSybCMLDoAMqd7FmzBKkgcpouMObqiVhosXrg==
-----END AGE ENCRYPTED FILE-----
- recipient: age1jpeh4s553taxkyxhzlshzqjfrtvmmp5lw0hmpgn3mdnmgzku332qe082dl
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBYZEMzQ0lydDR4YmJKczU1
UUVTTDlxRjZIWGFiVi81M2xCQVpvNFRIbkZVCnpiTGF2emVlb3g1YkluRWJHSEJL
NVhHcVgrNXdmajh4QUNudElWK2NMQ2cKLS0tIGlweFZhR2N2U1hrV2hpZ0F0dzRv
M0Q2ajg1aXM2UUJzVFRveXQ1MWJzWkEKHh+pa5qeVnBYFc5fAUSQVKYkcRn81/12
HiP5gBVEKZMt33ny8Pyrb8UtrLRe0UPBa2dhOlnq7v8ye48kgY+VFQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2024-04-16T09:43:39Z"
mac: ENC[AES256_GCM,data:OM1CJJ5GqOMw6jqV6HbL0+xvcmS1JFxq7Q+jCyVvAmC1+FGWBrC5LL4KgLT0BcDgf1QnkQ5EKjYLLQPuXQmZDUDB66M3KXryxoW1n3RfPziLDHSHtybevLlHZ2J+d0k/6Dmp7LkmGVUka/V2ZzFxKGXbwCuUU0clnLRMt47h388=,iv:VysReEM8UaKhrrXXWyUgEqqrrPyVdw4hKeoahSIaK/M=,tag:s2jG5ghsKPU28E1ZHown4Q==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.8.1

View file

@ -69,6 +69,9 @@ with config;
dnsutils
nix
# nix dev
dnscontrol # for updating internal DNS servers with homelab services
# Sensors etc
lm_sensors
cpufrequtils