Skip to content

Commit

Permalink
feat: adguard home + powerdns plz (#100)
Browse files Browse the repository at this point in the history
* hack

* feat: adguard + powerdns

---------

Co-authored-by: Truxnell <9149206+truxnell@users.noreply.github.com>
  • Loading branch information
truxnell and yunmanzr authored Apr 16, 2024
1 parent ab98634 commit 0dffbe9
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 50 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Binary file added docs/includes/assets/zed_alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions docs/monitoring/zed.md
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 1 addition & 1 deletion docs/motd.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
17 changes: 13 additions & 4 deletions nixos/hosts/dns01/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
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;

Expand Down
15 changes: 13 additions & 2 deletions nixos/hosts/dns02/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@
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;

Expand Down
3 changes: 2 additions & 1 deletion nixos/hosts/durandal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

gatus.enable = true;
homepage.enable = true;
backrest.enable = true;
# backrest.enable = true;

plex.enable = true;
tautulli.enable = true;
syncthing.enable = true;


};
mySystem.system.systemd.pushover-alerts.enable = false;

mySystem.nfs.nas.enable = true;
mySystem.persistentFolder = "/persistent";
Expand Down
90 changes: 90 additions & 0 deletions nixos/modules/nixos/services/adguardhome/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];

};

};
}
9 changes: 2 additions & 7 deletions nixos/modules/nixos/services/bind/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down
Loading

0 comments on commit 0dffbe9

Please sign in to comment.