Adguard Home (Adblocking + Local DNS Rewrite)

This commit is contained in:
Aleksandr Lebedev 2025-10-14 00:28:48 +02:00
parent ca80a34135
commit 32e166c762
5 changed files with 108 additions and 3 deletions

View file

@ -0,0 +1,72 @@
{
pkgs,
lib,
config,
...
}: {
services.adguardhome = {
enable = true;
host = "127.0.0.1";
port = 12270;
mutableSettings = false;
settings = {
users = [
# nix shell nixpkgs#mkpasswd --command mkpasswd --method=bcrypt
{
name = "kylekrein";
password = "$2b$05$W03hndNglgdYbbmsgR8Oxe5HaDi.ZeW9AIJvyB9oA9Bn8qDgYKFSy";
}
];
dns = {
bind_hosts = [
"127.0.0.1"
"::1"
"192.168.178.129"
];
upstream_dns = [
"94.140.14.14"
"94.140.15.15"
"1.1.1.1"
];
bootstrap_dns = [
"94.140.14.14"
"94.140.15.15"
"1.1.1.1"
];
};
filtering = {
protection_enabled = true;
filtering_enabled = true;
parental_enabled = false;
safe_search = {enabled = false;};
rewrites =
map (url: {
answer = "192.168.178.129";
domain = url;
}) [
"kylekrein.com"
"*.kylekrein.com"
];
};
filters =
map (url: {
enabled = true;
url = url;
}) [
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt" # AdGuard DNS filter
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_9.txt" # Malware
"https://adguardteam.github.io/HostlistsRegistry/assets/filter_11.txt" # Malicious URLs
#https://github.com/hagezi/dns-blocklists
"https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/pro.txt" # Pro blocking
"https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/tif.txt"
"https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/fake.txt"
"https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/popupads.txt"
];
};
};
networking.firewall.allowedTCPPorts = [53];
networking.firewall.allowedUDPPorts = [53];
}