all repos — nixfiles @ 703b38d2ff73a75c895e583d16f097c8ed791c22

System and user configuration, managed by nix and home-manager

router: fix local network DNS resolution

Alin
commit

703b38d2ff73a75c895e583d16f097c8ed791c22

parent

46a5c783938244f1fbab17cdc5d2688fc7328649

1 file changed, 33 insertions(+), 10 deletions(-)

changed files
M system/roles/router.nix → system/roles/router.nix
@@ -66,7 +66,13 @@ hosts = {
"${modem.deviceAddr}" = [ "${modem.hostname}.${domain} ${modem.hostname}" ]; - }; + } + // (lib.genAttrs myAddresses ( + lib.const [ + "${hostName}.${domain}" + "${hostName}" + ] + )); nameservers = lib.mkForce [ "::1" ]; nat = {
@@ -121,7 +127,7 @@ SpeedMeter = true;
}; }; networks = { - "40-${lan}" = rec { + "40-${lan}" = { matchConfig.Name = lan; address = [ "fd12:d04f:65d:42::1/56"
@@ -155,7 +161,7 @@ };
ipv6SendRAConfig = { Managed = true; OtherInformation = true; - DNS = map justAddress (builtins.filter (lib.strings.hasInfix ":") address); + DNS = (builtins.filter isv6 myAddresses) ++ [ "_link_local" ]; }; ipv6Prefixes = [ {
@@ -229,23 +235,22 @@ };
services.adguardhome.settings = let - dnsmasq = "[::1]:${toString config.services.dnsmasq.settings.port}"; - resolved = builtins.head config.services.resolved.settings.Resolve.DNSStubListenerExtra; + mkHostPort = (addr: "${wrapv6 addr}:${toString config.services.dnsmasq.settings.port}"); + dnsmasqAddrs = map mkHostPort (builtins.filter isv6 myAddresses); mkTLSHost = p: "tls://${p.hostname}"; in { dns = { upstream_dns = (map mkTLSHost allProviders) ++ [ # [/domain1/domain2/domainN/]upstreamString - "[/${domain}/]${dnsmasq}" + "[/${domain}/]${lib.strings.join " " dnsmasqAddrs}" # [//]: unqualified only - "[//]${resolved}" ]; bootstrap_dns = mainProvider.addresses; bootstrap_prefer_ipv6 = true; use_private_ptr_resolvers = true; - local_ptr_upstreams = [ dnsmasq ]; + local_ptr_upstreams = dnsmasqAddrs; }; };
@@ -307,6 +312,25 @@ dhcp-rapid-commit = true;
dhcp-range = [ "10.0.1.10,10.0.250.250,48h" "fd12:d04f:65d:42::10,fd12:d04f:65d:42::ffff,64,48h" + # "set:ra6,::,constructor:${lan},ra-stateless" + ]; + + # configure static allocations in /etc/ethers + # format: + # [hwaddr] [name|ipv4 address] + read-ethers = true; + # use addn-hosts for resolving names of static allocations + addn-hosts = [ "/etc/dnsmasq-hosts" ]; + + dhcp-option = [ + # 0.0.0.0 means the address of the system running dnsmasq + "option:dns-server,0.0.0.0" + "option:ntp-server,0.0.0.0" + + # [::] means the *global* address of the system running dnsmasq + # [fd00::] refers to a ULA + # [fe80::] refers to a link-local address + "option6:dns-server,[fd00::],[fe80::]" ]; no-resolv = true;
@@ -318,8 +342,7 @@ bogus-priv = true;
quiet-ra = true; - # resolved will look there anyway - no-hosts = true; + expand-hosts = true; localise-queries = false; local = [