From a967b6ab05c8a1573123ffec22308010ba2c3432 Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 21 Nov 2021 20:26:08 +0100 Subject: [PATCH] nixos: dns ipv6 support --- hosts.nix | 3 +++ nixos/hosts/dns/configuration.nix | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hosts.nix b/hosts.nix index 8b4a3c1..69fe10e 100644 --- a/hosts.nix +++ b/hosts.nix @@ -2,6 +2,7 @@ { hostname = "edgerouter"; ip = "10.42.42.1"; + ip6 = "2001:41f0:9639:1:b6fb:e4ff:fe53:9c0"; mac = "B4:FB:E4:53:9C:0A"; nix = false; } @@ -9,6 +10,7 @@ hostname = "nuc"; ip = "10.42.42.42"; mac = "1C:69:7A:62:30:88"; + ip6 = ""; nix = false; } { @@ -20,6 +22,7 @@ { hostname = "home-assistant"; ip = "10.42.42.8"; + ip6 = "2001:41f0:9639:1:bfe7:3fd9:75de:cbee"; mac = "74:40:be:48:85:a4"; nix = false; } diff --git a/nixos/hosts/dns/configuration.nix b/nixos/hosts/dns/configuration.nix index 565d124..c450dcb 100644 --- a/nixos/hosts/dns/configuration.nix +++ b/nixos/hosts/dns/configuration.nix @@ -1,8 +1,12 @@ { config, pkgs, hosts, ... }: let localdomain = "olympus"; + ipv6Hosts = builtins.filter (builtins.hasAttr ip6) hosts; + localData = { hostname, ip, ... }: ''"${hostname}.${localdomain}. A ${ip}"''; + local6Data = { hostname, ip6, ... }: ''"${hostname}.${localdomain}. AAAA ${ip6}"''; ptrData = { hostname, ip, ... }: ''"${ip} ${hostname}.${localdomain}"''; + ptr6Data = { hostname, ip6, ... }: ''"${ip6} ${hostname}.${localdomain}"''; in { imports = [ ]; @@ -32,8 +36,8 @@ in { interface = [ "0.0.0.0" "::0" ]; local-zone = ''"${localdomain}." transparent''; - local-data = map localData hosts; - local-data-ptr = map ptrData hosts; + local-data = (map localData hosts) ++ (map local6Data ipv6Hosts); + local-data-ptr = (map ptrData hosts); access-control = [ "127.0.0.1/32 allow_snoop"