setup unbound dns
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
../../modules/remote-builder.nix
|
../../modules/remote-builder.nix
|
||||||
../../modules/borgbackup.nix
|
../../modules/borgbackup.nix
|
||||||
./topology.nix
|
./topology.nix
|
||||||
|
../../modules/unbound.nix
|
||||||
|
../../modules/unbound-auth.nix
|
||||||
self.nixosModules.gitea
|
self.nixosModules.gitea
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,8 @@
|
|||||||
./topology.nix
|
./topology.nix
|
||||||
|
|
||||||
../../system
|
../../system
|
||||||
../../modules/borgbackup.nix
|
../../modules/unbound.nix
|
||||||
|
../../modules/unbound-auth.nix
|
||||||
self.inputs.clan-core.clanModules.state-version
|
|
||||||
self.inputs.clan-core.clanModules.trusted-nix-caches
|
|
||||||
|
|
||||||
self.inputs.home-manager.nixosModules.home-manager
|
self.inputs.home-manager.nixosModules.home-manager
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
# Tailscale seems to break when not using resolved
|
# Tailscale seems to break when not using resolved
|
||||||
services.resolved.enable = true;
|
# services.resolved.enable = true;
|
||||||
networking.useDHCP = true;
|
networking.useDHCP = true;
|
||||||
networking.interfaces.tailscale0.useDHCP = false;
|
networking.interfaces.tailscale0.useDHCP = false;
|
||||||
}
|
}
|
||||||
|
|||||||
30
modules/unbound-auth.nix
Normal file
30
modules/unbound-auth.nix
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
services.unbound = {
|
||||||
|
settings = {
|
||||||
|
auth-zone = [
|
||||||
|
{
|
||||||
|
name = "home.rpqt.fr.";
|
||||||
|
zonefile = builtins.toFile "home.rpqt.fr.zone" ''
|
||||||
|
$TTL 3600 ; 1 Hour
|
||||||
|
$ORIGIN home.rpqt.fr.
|
||||||
|
home.rpqt.fr. IN SOA ns1 admin.rpqt.fr. (
|
||||||
|
2025063000 ; serial
|
||||||
|
10800 ; refresh
|
||||||
|
3600 ; retry
|
||||||
|
604800 ; expire
|
||||||
|
300 ; minimum
|
||||||
|
)
|
||||||
|
|
||||||
|
@ 1D IN NS ns1.home.rpqt.fr.
|
||||||
|
|
||||||
|
ns1 10800 IN CNAME crocus.home.rpqt.fr.
|
||||||
|
ns2 10800 IN CNAME genepi.home.rpqt.fr.
|
||||||
|
|
||||||
|
crocus 10800 IN AAAA fd80:150d:17cc:2ae:6999:9380:150d:17cc
|
||||||
|
genepi 10800 IN AAAA fd80:150d:17cc:2ae:6999:9358:3e0e:d738
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
100
modules/unbound.nix
Normal file
100
modules/unbound.nix
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
self,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
domain = "home.rpqt.fr";
|
||||||
|
machines = {
|
||||||
|
genepi = {
|
||||||
|
subdomains = [
|
||||||
|
"glance"
|
||||||
|
"grafana"
|
||||||
|
"images"
|
||||||
|
"rss"
|
||||||
|
"tw"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
zerotierInterface = "zts7mq7onf";
|
||||||
|
machinesZerotierIpRecords =
|
||||||
|
lib.map
|
||||||
|
(
|
||||||
|
host:
|
||||||
|
''"${host}.infra.rpqt.fr. 10800 IN AAAA ${
|
||||||
|
self.nixosConfigurations.${host}.config.clan.core.vars.generators.zerotier.files.zerotier-ip.value
|
||||||
|
}"''
|
||||||
|
)
|
||||||
|
[
|
||||||
|
"crocus"
|
||||||
|
"genepi"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.resolved.enable = false;
|
||||||
|
|
||||||
|
networking.firewall.interfaces.${zerotierInterface} = {
|
||||||
|
allowedTCPPorts = [ 53 ];
|
||||||
|
allowedUDPPorts = [ 53 ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.unbound = {
|
||||||
|
enable = true;
|
||||||
|
resolveLocalQueries = true;
|
||||||
|
checkconf = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
server = {
|
||||||
|
interface = [
|
||||||
|
"127.0.0.1"
|
||||||
|
"::1"
|
||||||
|
"::0"
|
||||||
|
];
|
||||||
|
access-control = [
|
||||||
|
"127.0.0.1 allow"
|
||||||
|
"${config.clan.core.networking.zerotier.subnet} allow"
|
||||||
|
];
|
||||||
|
local-zone = [
|
||||||
|
''"*.home.rpqt.fr." redirect''
|
||||||
|
];
|
||||||
|
local-data =
|
||||||
|
# machinesZerotierIpRecords ++
|
||||||
|
lib.concatMap (
|
||||||
|
host:
|
||||||
|
lib.map (
|
||||||
|
subdomain:
|
||||||
|
''"${subdomain}.${domain}. 10800 IN AAAA ${
|
||||||
|
self.nixosConfigurations.${host}.config.clan.core.vars.generators.zerotier.files.zerotier-ip.value
|
||||||
|
}"''
|
||||||
|
) machines.${host}.subdomains
|
||||||
|
) (lib.attrNames machines);
|
||||||
|
private-address = [
|
||||||
|
"127.0.0.1/8"
|
||||||
|
"${config.clan.core.networking.zerotier.subnet}"
|
||||||
|
];
|
||||||
|
private-domain = [
|
||||||
|
"home.rpqt.fr"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
forward-zone = [
|
||||||
|
{
|
||||||
|
name = ".";
|
||||||
|
forward-tls-upstream = true;
|
||||||
|
forward-addr = [
|
||||||
|
"9.9.9.9#dns.quad9.net"
|
||||||
|
"149.112.112.112#dns.quad9.net"
|
||||||
|
"1.1.1.1@853#cloudflare-dns.com"
|
||||||
|
"1.0.0.1@853#cloudflare-dns.com"
|
||||||
|
"2606:4700:4700::1111@853#cloudflare-dns.com"
|
||||||
|
"2606:4700:4700::1001@853#cloudflare-dns.com"
|
||||||
|
"8.8.8.8#dns.google"
|
||||||
|
"8.8.4.4#dns.google"
|
||||||
|
"2001:4860:4860::8888#dns.google"
|
||||||
|
"2001:4860:4860::8844#dns.google"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user