hosts/plover: update networking setup

This commit is contained in:
Gabriel Arazas 2023-02-05 11:45:06 +08:00
parent b1925b99a6
commit 97b9a3ff10
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 18 additions and 60 deletions

View File

@ -5,11 +5,11 @@
# from nixos-generators. # from nixos-generators.
let let
inherit (builtins) toString; inherit (builtins) toString;
inherit (import ./networks.nix) interfaces; inherit (import ./networks.nix) interfaces privateIPv6Prefix;
# 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 = [ "ens10" "enp0s10" ]; mainEthernetInterfaceNames = [ "ens3" "enp0s3" ];
internalEthernetInterfaceNames = [ "ens11" "enp0s11" ]; internalEthernetInterfaceNames = [ "ens10" "enp0s10" ];
in in
{ {
imports = [ imports = [
@ -58,63 +58,33 @@ in
# 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/
networks = { networks = {
"20-wan" = { "10-wan" = with interfaces.main'; {
matchConfig.Name = lib.concatStringsSep " " mainEthernetInterfaceNames; matchConfig.Name = lib.concatStringsSep " " mainEthernetInterfaceNames;
# Setting the primary static IPs. # Setting up IPv6.
address = with interfaces; [ address = [ "${IPv6.address}/64" ];
# The public IPs. gateway = [ IPv6.gateway ];
"${main'.IPv4.address}/32"
"${main'.IPv6.address}/128"
];
networkConfig.IPForward = true; networkConfig = {
DHCP = "yes";
gateway = [ IPForward = true;
interfaces.main'.IPv4.gateway IPMasquerade = "ipv4";
interfaces.main'.IPv6.gateway
];
routes = [
{ routeConfig.Gateway = interfaces.main'.IPv6.gateway; }
{ routeConfig.Destination = interfaces.main'.IPv4.address; }
{
routeConfig = {
Gateway = interfaces.main'.IPv4.gateway;
GatewayOnLink = true;
}; };
}
];
}; };
# The internal server.
"20-lan" = with interfaces.internal; { "20-lan" = with interfaces.internal; {
matchConfig.Name = lib.concatStringsSep " " internalEthernetInterfaceNames; matchConfig.Name = lib.concatStringsSep " " internalEthernetInterfaceNames;
address = [ address = [
"${IPv4.address}/16" "${IPv4.address}/32"
"${IPv6.address}/64" "${IPv6.address}/128"
]; ];
gateway = [ gateway = [
IPv4.gateway IPv4.gateway
IPv6.gateway IPv6.gateway
]; ];
routes = [
{ routeConfig.Gateway = IPv6.gateway; }
{ routeConfig.Destination = IPv4.address; }
{
routeConfig = {
Gateway = IPv4.gateway;
GatewayOnLink = true;
};
}
];
};
"60-internal" = {
matchConfig.Name = "ens*";
networkConfig.DHCP = "yes";
}; };
}; };
}; };

View File

@ -31,7 +31,7 @@ rec {
}; };
# /16 block for IPv4, /64 for IPv6. # /16 block for IPv4, /64 for IPv6.
main = { internal = {
IPv4 = { IPv4 = {
address = "172.27.0.1"; address = "172.27.0.1";
gateway = ploverInternalNetworkGateway; gateway = ploverInternalNetworkGateway;
@ -42,18 +42,6 @@ rec {
}; };
}; };
# /16 block for IPv4, /64 for IPv6.
internal = {
IPv4 = {
address = "172.27.0.2";
gateway = ploverInternalNetworkGateway;
};
IPv6 = {
address = "${privateIPv6Prefix}:2::";
gateway = ipv6Gateway;
};
};
# /16 BLOCK for IPv4, /64 for IPv6. # /16 BLOCK for IPv4, /64 for IPv6.
wireguard0 = { wireguard0 = {
IPv4 = { IPv4 = {