hosts/plover: move into systemd-networkd for network setup

This commit is contained in:
Gabriel Arazas 2023-01-16 11:44:21 +08:00
parent 708ed8137c
commit 8e07223c97
2 changed files with 55 additions and 7 deletions

View File

@ -3,6 +3,11 @@
# Most of the filesystems listed here are supposed to be overriden to default # Most of the filesystems listed here are supposed to be overriden to default
# settings of whatever image format configuration this host system will import # settings of whatever image format configuration this host system will import
# from nixos-generators. # from nixos-generators.
let
network = import ./networks.nix;
inherit (network) publicIP publicIPv6 privateNetworkGatewayIP;
in
{ {
imports = [ imports = [
(modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/qemu-guest.nix")
@ -33,15 +38,48 @@
networking = { networking = {
useDHCP = false; useDHCP = false;
enableIPv6 = true; useNetworkd = true;
dhcpcd.persistent = true; # We're using networkd to configure so we're disabling this
# service.
dhcpcd.enable = false;
};
interfaces = { # The interface configuration is based from the following discussion:
ens3 = { # https://discourse.nixos.org/t/nixos-on-hetzner-cloud-servers-ipv6/221/
useDHCP = true; systemd.network = {
}; enable = true;
ens10.useDHCP = true; networks."20-wan" = {
matchConfig.Name = "ens3";
address = [
# Public IPs.
publicIP
"${publicIPv6}1/64"
# The private network IP.
"172.23.0.1/32"
# Randomly generate from the IPv6 range.
"::"
];
routes = [
# Configuring the route with the gateway addresses for this network.
{ routeConfig.Gateway = "fe80::1"; }
{ routeConfig.Destination = privateNetworkGatewayIP; }
{ routeConfig = { Gateway = privateNetworkGatewayIP; GatewayOnLink = true; }; }
# Private addresses.
{ routeConfig = { Destination = "172.16.0.0/12"; Type = "unreachable"; }; }
{ routeConfig = { Destination = "192.168.0.0/16"; Type = "unreachable"; }; }
{ routeConfig = { Destination = "10.0.0.0/8"; Type = "unreachable"; }; }
{ routeConfig = { Destination = "fc00::/7"; Type = "unreachable"; }; }
];
}; };
}; };
# This is to look out for any errors that will occur for my networking setup
# which is always a possibility.
systemd.services.systemd-networkd.serviceConfig.Environment = "SYSTEMD_LOG_LEVEL=debug";
} }

View File

@ -0,0 +1,10 @@
# It just contains a set of network-related variables mainly used for
# network-related services. Make sure to change this every time you migrate to
# a new server.
{
publicIP = "95.217.212.19/32";
publicIPv6 = "2a01:4f9:c011:a448::";
privateIPNetworkRange = "172.16.0.0/32";
privateNetworkGatewayIP = "172.16.0.1/32";
}