hosts/plover/services/networking: fix routing issue for WAN network interface

This commit is contained in:
Gabriel Arazas 2024-09-28 19:01:25 +08:00
parent 2efee4c1a7
commit 4fd843bd92
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360

View File

@ -1,11 +1,11 @@
{ config, lib, pkgs, modulesPath, ... }: { config, lib, ... }:
let let
hostCfg = config.hosts.plover; hostCfg = config.hosts.plover;
cfg = hostCfg.services.networking; cfg = hostCfg.services.networking;
# This is just referring to the same interface just with alternative names. # This is just referring to the same interface just with alternative names.
mainEthernetInterfaceNames = [ "eth0" ]; mainEthernetInterfaceNames = [ "eth0" "enp1s0" ];
internalEthernetInterfaceNames = [ "enp7s0" ]; internalEthernetInterfaceNames = [ "enp7s0" ];
inherit (config.state.network) interfaces; inherit (config.state.network) interfaces;
in in
@ -60,7 +60,7 @@ in
# https://discourse.nixos.org/t/nixos-on-hetzner-cloud-servers-ipv6/221/ # https://discourse.nixos.org/t/nixos-on-hetzner-cloud-servers-ipv6/221/
systemd.network = { systemd.network = {
enable = true; enable = true;
wait-online.ignoredInterfaces = [ "lo" interfaces.lan.ifname ]; wait-online.ignoredInterfaces = [ "lo" ];
# For more information, you can look at Hetzner documentation from # For more information, you can look at Hetzner documentation from
# https://docs.hetzner.com/robot/dedicated-server/ip/additional-ip-adresses/ # https://docs.hetzner.com/robot/dedicated-server/ip/additional-ip-adresses/
@ -71,10 +71,16 @@ in
matchConfig.Name = lib.concatStringsSep " " mainEthernetInterfaceNames; matchConfig.Name = lib.concatStringsSep " " mainEthernetInterfaceNames;
# Setting up IPv6. # Setting up IPv6.
address = [ "${wan.ipv6}/64" ]; address = [
"${wan.ipv4}/32"
"${wan.ipv6}/64"
];
gateway = [ wan.ipv6Gateway ]; gateway = [ wan.ipv6Gateway ];
dns = [ dns = [
"185.12.64.1"
"185.12.64.2"
"2a01:4ff:ff00::add:2" "2a01:4ff:ff00::add:2"
"2a01:4ff:ff00::add:1" "2a01:4ff:ff00::add:1"
] ]
@ -85,16 +91,17 @@ in
# Setting up some other networking thingy. # Setting up some other networking thingy.
domains = [ config.networking.domain ]; domains = [ config.networking.domain ];
networkConfig = {
DHCP = "ipv4";
IPv4Forwarding = true;
IPv6Forwarding = true;
LinkLocalAddressing = "ipv6"; routes = lib.singleton {
IPv6AcceptRA = true; routeConfig = {
Gateway = wan.ipv4Gateway;
GatewayOnLink = true;
}; };
}; };
linkConfig.RequiredForOnline = "routable";
};
# The interface for our LAN. # The interface for our LAN.
"20-lan" = let "20-lan" = let
inherit (interfaces) lan; inherit (interfaces) lan;
@ -125,6 +132,7 @@ in
]; ];
networkConfig.IPv6AcceptRA = true; networkConfig.IPv6AcceptRA = true;
linkConfig.RequiredForOnline = "routable";
}; };
}; };
}; };