hosts/plover: update networking setup

This commit is contained in:
Gabriel Arazas 2023-01-19 20:12:14 +08:00
parent 2ee3f755fd
commit 5fab811812
2 changed files with 52 additions and 7 deletions

View File

@ -5,9 +5,11 @@
# from nixos-generators.
let
network = import ./networks.nix;
inherit (network) publicIP publicIPv6 privateNetworkGatewayIP;
in
inherit (network) publicIP' publicIPv6 publicIPv6PrefixLength privateNetworkGatewayIP;
# This is just referring to the same interface just with alternative names.
mainEthernetInterfaceNames = [ "ens3" "enp0s3" ];
in
{
imports = [
(modulesPath + "/profiles/qemu-guest.nix")
@ -50,9 +52,47 @@ in
# https://discourse.nixos.org/t/nixos-on-hetzner-cloud-servers-ipv6/221/
systemd.network = {
enable = true;
networks."20-wan" = {
matchConfig.Name = "en*";
networkConfig.DHCP = "yes";
# For more information, you can look at Hetzner documentation from
# https://docs.hetzner.com/robot/dedicated-server/ip/additional-ip-adresses/
networks = {
"60-wan" = {
matchConfig.Name = lib.concatStringsSep " " mainEthernetInterfaceNames;
# Setting the primary static IPs.
address = [
publicIP'
# The public IPv6 is assigned to a server so we'll to have to go with
# something else.
"${publicIPv6}1/${publicIPv6PrefixLength}"
];
networkConfig = {
DHCP = "yes";
IPForward = true;
IPMasquerade = "both";
};
routes = [
{ routeConfig.Gateway = "fe80::1"; }
{ routeConfig.Destination = publicIP'; }
{
routeConfig = {
Gateway = publicIP';
GatewayOnLink = true;
};
}
];
};
# This is to make use of the remaining ethernet interfaces as we can
# build a local network.
"60-dhcpv6-pd-downstreams" = {
matchConfig.Name = "en*";
networkConfig.DHCP = "yes";
};
};
};

View File

@ -1,9 +1,14 @@
# 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";
rec {
publicIP = "95.217.212.19";
publicIPPrefixLength = 32;
publicIP' = "${publicIP}/${publicIPPrefixLength}";
publicIPv6 = "2a01:4f9:c011:a448::";
publicIPv6PrefixLength = 64;
publicIPv6' = "${publicIPv6}/${publicIPv6PrefixLength}";
privateIPNetworkRange = "172.16.0.0/32";
privateNetworkGatewayIP = "172.16.0.1/32";