diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-03-15 16:37:42 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-03-15 16:37:42 +0100 |
commit | 366cf64e848eebea98f9d9bb95e623597af74669 (patch) | |
tree | 949daf1e7b58ce2370b16663fb535ca10bc46bf1 /hosts/vidhar/dns/default.nix | |
parent | 6dd45923b4bba68eb08b9d3ec43dc924734dd8c8 (diff) | |
download | nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.gz nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.bz2 nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.xz nixos-366cf64e848eebea98f9d9bb95e623597af74669.zip |
vidhar: ddns
Diffstat (limited to 'hosts/vidhar/dns/default.nix')
-rw-r--r-- | hosts/vidhar/dns/default.nix | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/hosts/vidhar/dns/default.nix b/hosts/vidhar/dns/default.nix new file mode 100644 index 00000000..19a121f6 --- /dev/null +++ b/hosts/vidhar/dns/default.nix | |||
@@ -0,0 +1,127 @@ | |||
1 | { config, lib, pkgs, ... }: | ||
2 | |||
3 | with lib; | ||
4 | |||
5 | let | ||
6 | knotKeys = let | ||
7 | dir = ./keys; | ||
8 | toKeyInfo = name: v: | ||
9 | if v == "regular" || v == "symlink" | ||
10 | then { path = dir + "/${name}"; inherit name; } | ||
11 | else null; | ||
12 | in filter (v: v != null) (mapAttrsToList toKeyInfo (builtins.readDir dir)); | ||
13 | in { | ||
14 | config = { | ||
15 | services.unbound = { | ||
16 | enable = true; | ||
17 | resolveLocalQueries = false; | ||
18 | stateDir = "/var/lib/unbound"; | ||
19 | localControlSocketPath = "/run/unbound/unbound.ctl"; | ||
20 | settings = { | ||
21 | server = { | ||
22 | interface = ["127.0.0.1" "10.141.0.1" "::0"]; | ||
23 | prefer-ip6 = true; | ||
24 | access-control = ["0.0.0.0/0 allow" "::/0 allow"]; | ||
25 | root-hints = "${pkgs.dns-root-data}/root.hints"; | ||
26 | |||
27 | num-threads = 12; | ||
28 | so-reuseport = true; | ||
29 | msg-cache-slabs = 16; | ||
30 | rrset-cache-slabs = 16; | ||
31 | infra-cache-slabs = 16; | ||
32 | key-cache-slabs = 16; | ||
33 | |||
34 | rrset-cache-size = "100m"; | ||
35 | msg-cache-size = "50m"; | ||
36 | outgoing-range = 8192; | ||
37 | num-queries-per-thread = 4096; | ||
38 | |||
39 | so-rcvbuf = "4m"; | ||
40 | so-sndbuf = "4m"; | ||
41 | |||
42 | # serve-expired = true; | ||
43 | # serve-expired-ttl = 86400; | ||
44 | # serve-expired-reply-ttl = 0; | ||
45 | |||
46 | prefetch = true; | ||
47 | prefetch-key = true; | ||
48 | |||
49 | minimal-responses = false; | ||
50 | |||
51 | extended-statistics = true; | ||
52 | |||
53 | rrset-roundrobin = true; | ||
54 | use-caps-for-id = true; | ||
55 | |||
56 | local-zone = [ | ||
57 | "141.10.in-addr.arpa transparent" | ||
58 | "yggdrasil transparent" | ||
59 | ]; | ||
60 | domain-insecure = [ | ||
61 | "141.10.in-addr.arpa" | ||
62 | "yggdrasil" | ||
63 | ]; | ||
64 | }; | ||
65 | |||
66 | stub-zone = map (name: { | ||
67 | inherit name; | ||
68 | stub-addr = "127.0.0.1@5353"; | ||
69 | stub-first = true; | ||
70 | stub-no-cache = true; | ||
71 | stub-prime = false; | ||
72 | }) ["yggdrasil" "lan.yggdrasil" "mgmt.yggdrasil" "arpa.in-addr.10.141" "arpa.in-addr.10.141.0" "arpa.in-addr.10.141.1"]; | ||
73 | }; | ||
74 | }; | ||
75 | |||
76 | services.knot = { | ||
77 | enable = true; | ||
78 | keyFiles = map ({name, ...}: config.sops.secrets.${name}.path) knotKeys; | ||
79 | extraConfig = '' | ||
80 | server: | ||
81 | listen: 127.0.0.1@5353 | ||
82 | listen: ::1@5353 | ||
83 | |||
84 | acl: | ||
85 | - id: local_acl | ||
86 | key: local_key | ||
87 | action: update | ||
88 | |||
89 | template: | ||
90 | - id: local_zone | ||
91 | storage: /var/lib/knot | ||
92 | zonefile-sync: -1 | ||
93 | zonefile-load: difference-no-serial | ||
94 | serial-policy: dateserial | ||
95 | journal-content: all | ||
96 | semantic-checks: on | ||
97 | acl: [local_acl] | ||
98 | |||
99 | zone: | ||
100 | - domain: yggdrasil | ||
101 | template: local_zone | ||
102 | file: ${./zones/yggdrasil.soa} | ||
103 | - domain: lan.yggdrasil | ||
104 | template: local_zone | ||
105 | file: ${./zones/yggdrasil.lan.soa} | ||
106 | - domain: mgmt.yggdrasil | ||
107 | template: local_zone | ||
108 | file: ${./zones/yggdrasil.mgmt.soa} | ||
109 | - domain: 141.10.in-addr.arpa | ||
110 | template: local_zone | ||
111 | file: ${./zones/arpa.in-addr.10.141.soa} | ||
112 | - domain: 0.141.10.in-addr.arpa | ||
113 | template: local_zone | ||
114 | file: ${./zones/arpa.in-addr.10.141.0.soa} | ||
115 | - domain: 1.141.10.in-addr.arpa | ||
116 | template: local_zone | ||
117 | file: ${./zones/arpa.in-addr.10.141.1.soa} | ||
118 | ''; | ||
119 | }; | ||
120 | |||
121 | sops.secrets = listToAttrs (map ({name, path}: nameValuePair name { | ||
122 | format = "binary"; | ||
123 | owner = "knot"; | ||
124 | sopsFile = path; | ||
125 | }) knotKeys); | ||
126 | }; | ||
127 | } | ||