From 3d09d2883e7d1b25901c0da8829bdd6daef24862 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Mon, 2 Dec 2024 08:59:02 +0300 Subject: [PATCH] Home: Advertise local v6 subnet. --- container/Dns.nix | 2 +- host/x86_64-linux/home/Ddns.nix | 22 ---------------------- host/x86_64-linux/home/Network.nix | 30 +++++++++++++++++++----------- 3 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 host/x86_64-linux/home/Ddns.nix diff --git a/container/Dns.nix b/container/Dns.nix index 6de7bd6..b0585f1 100644 --- a/container/Dns.nix +++ b/container/Dns.nix @@ -112,7 +112,7 @@ in { in { # All subdomains to current host. # ${config.container.domain} = config.container.host; - "voronind.com" = "10.0.0.1"; + "voronind.com" = "10.0.0.1,fd09:8d46:b26::1"; } // block "gosuslugi.ru" // block "rutube.ru" diff --git a/host/x86_64-linux/home/Ddns.nix b/host/x86_64-linux/home/Ddns.nix deleted file mode 100644 index 1564852..0000000 --- a/host/x86_64-linux/home/Ddns.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ ... }: { - services.cloudflare-dyndns = { - enable = true; - apiTokenFile = "/storage/hot/container/ddns/data/token"; - deleteMissing = false; - ipv4 = true; - ipv6 = true; - proxied = false; - domains = let - domain = "voronind.com"; - in [ - domain - ] ++ map (sub: "${sub}.${domain}") [ - "cloud" - "git" - "mail" - "office" - "paste" - "vpn" - ]; - }; -} diff --git a/host/x86_64-linux/home/Network.nix b/host/x86_64-linux/home/Network.nix index 9e86fab..d6bb253 100644 --- a/host/x86_64-linux/home/Network.nix +++ b/host/x86_64-linux/home/Network.nix @@ -1,5 +1,5 @@ -# 10.0.0.0/24 - phys clients (lan). -# 10.1.0.0/24 - containers. +# 10.0.0.0/24 & fd09:8d46:0b26::/48 - phys clients (lan). +# 10.1.0.0/24 & fd76:c80a:8e86::/48 - containers. # 10.1.1.0/24 - vpn clients. { config, @@ -8,9 +8,10 @@ util, ... }: let - external = "188.242.247.132"; # Wan host IP address. - internal = "10.0.0.1"; # Lan host IP address. - wifi = "10.0.0.2"; # Wifi router IP address. + external = "188.242.247.132"; # Wan host IP address. + internal = "10.0.0.1"; # Lan host IP address. + external6 = "2a05:3580:f42c:c800:aaa1:59ff:fe47:fda2"; # Wan host IP6 address. + internal6 = "fd09:8d46:b26::1"; # Lan host IP6 address. lan = "br0"; # Lan interface. wan = "enp8s0"; # Wan interface. @@ -78,10 +79,10 @@ in { }; "30-${lan}" = { matchConfig.Name = lan; - bridgeConfig = {}; linkConfig.RequiredForOnline = "carrier"; address = [ - "10.0.0.1/24" + "${internal}/24" + "${internal6}/48" ]; networkConfig = { DHCPPrefixDelegation = true; @@ -90,16 +91,22 @@ in { IPv6SendRA = true; }; ipv6SendRAConfig = { - # EmitDNS = true; - # DNS = ":self"; + EmitDNS = true; + DNS = internal6; }; + ipv6Prefixes = [ + { + AddressAutoconfiguration = true; + Prefix = "${internal6}/64"; + } + ]; dhcpPrefixDelegationConfig = { Announce = true; SubnetId = 1; UplinkInterface = wan; }; dhcpServerConfig = { - DNS = "10.0.0.1"; + DNS = internal; DefaultLeaseTimeSec = "12h"; EmitDNS = true; EmitNTP = true; @@ -108,7 +115,7 @@ in { MaxLeaseTimeSec = "24h"; PoolOffset = 100; PoolSize = 150; - ServerAddress = "10.0.0.1/24"; + ServerAddress = "${internal}/24"; Timezone = const.timeZone; UplinkInterface = wan; }; @@ -176,6 +183,7 @@ in { # Full access from Lan. iptables -I INPUT -j ACCEPT -i ${lan} -d ${internal} + ip6tables -I INPUT -j ACCEPT -i ${lan} -d ${internal6} # Allow DHCP. iptables -I INPUT -j ACCEPT -i ${lan} -p udp --dport 67