simplify dns
This commit is contained in:
parent
8e0a0ffe71
commit
0227d2c10c
2 changed files with 5 additions and 50 deletions
|
@ -1,15 +1,5 @@
|
||||||
{ config, pkgs, hosts, flat_hosts, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
{
|
||||||
inherit (builtins) filter hasAttr attrNames;
|
|
||||||
domains = attrNames hosts;
|
|
||||||
ipv4Host = filter (hasAttr "ip") flat_hosts;
|
|
||||||
ipv6Hosts = filter (hasAttr "ip6") flat_hosts;
|
|
||||||
|
|
||||||
localData = { hostname, realm, ip, ... }: ''"${hostname}.${realm}. A ${ip}"'';
|
|
||||||
local6Data = { hostname, realm, ip6, ... }: ''"${hostname}.${realm}. AAAA ${ip6}"'';
|
|
||||||
ptrData = { hostname, realm, ip, ... }: ''"${ip} ${hostname}.${realm}"'';
|
|
||||||
ptr6Data = { hostname, realm, ip6, ... }: ''"${ip6} ${hostname}.${realm}"'';
|
|
||||||
in {
|
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
|
|
||||||
# This value determines the NixOS release from which the default
|
# This value determines the NixOS release from which the default
|
||||||
|
@ -26,43 +16,9 @@ in {
|
||||||
networking.firewall.allowedTCPPorts = [ 53 ];
|
networking.firewall.allowedTCPPorts = [ 53 ];
|
||||||
networking.firewall.allowedUDPPorts = [ 53 ];
|
networking.firewall.allowedUDPPorts = [ 53 ];
|
||||||
|
|
||||||
services.unbound = {
|
services.v.dns = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.v.unbound;
|
openFirewall = true;
|
||||||
settings = {
|
mode = "server";
|
||||||
server = {
|
|
||||||
use-syslog = "yes";
|
|
||||||
module-config = ''"validator iterator"'';
|
|
||||||
interface-automatic = "yes";
|
|
||||||
interface = [ "0.0.0.0" "::0" ];
|
|
||||||
|
|
||||||
local-zone = map (localdomain: ''"${localdomain}}." transparent'') domains;
|
|
||||||
local-data = (map localData ipv4Host) ++ (map local6Data ipv6Hosts);
|
|
||||||
local-data-ptr = (map ptrData ipv4Host) ++ (map ptr6Data ipv6Hosts);
|
|
||||||
|
|
||||||
access-control = [
|
|
||||||
"127.0.0.1/32 allow_snoop"
|
|
||||||
"::1 allow_snoop"
|
|
||||||
"10.42.0.0/16 allow"
|
|
||||||
"127.0.0.0/8 allow"
|
|
||||||
"192.168.0.0/23 allow"
|
|
||||||
"192.168.2.0/24 allow"
|
|
||||||
"::1/128 allow"
|
|
||||||
];
|
|
||||||
private-address = [
|
|
||||||
"127.0.0.0/8"
|
|
||||||
"10.0.0.0/8"
|
|
||||||
"::ffff:a00:0/104"
|
|
||||||
"172.16.0.0/12"
|
|
||||||
"::ffff:ac10:0/108"
|
|
||||||
"169.254.0.0/16"
|
|
||||||
"::ffff:a9fe:0/112"
|
|
||||||
"192.168.0.0/16"
|
|
||||||
"::ffff:c0a8:0/112"
|
|
||||||
"fd00::/8"
|
|
||||||
"fe80::/10"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: Set up DNS on my laptop to prevent slow networking when servers are down
|
|
||||||
nameservers = [
|
nameservers = [
|
||||||
"127.0.0.1"
|
"127.0.0.1"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue