mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
hosts/plover: move into systemd-networkd for network setup
This commit is contained in:
parent
708ed8137c
commit
8e07223c97
@ -3,6 +3,11 @@
|
||||
# Most of the filesystems listed here are supposed to be overriden to default
|
||||
# settings of whatever image format configuration this host system will import
|
||||
# from nixos-generators.
|
||||
let
|
||||
network = import ./networks.nix;
|
||||
inherit (network) publicIP publicIPv6 privateNetworkGatewayIP;
|
||||
in
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
@ -33,15 +38,48 @@
|
||||
|
||||
networking = {
|
||||
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 = {
|
||||
ens3 = {
|
||||
useDHCP = true;
|
||||
};
|
||||
ens10.useDHCP = true;
|
||||
# The interface configuration is based from the following discussion:
|
||||
# https://discourse.nixos.org/t/nixos-on-hetzner-cloud-servers-ipv6/221/
|
||||
systemd.network = {
|
||||
enable = 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";
|
||||
}
|
||||
|
10
hosts/plover/modules/hardware/networks.nix
Normal file
10
hosts/plover/modules/hardware/networks.nix
Normal 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";
|
||||
}
|
Loading…
Reference in New Issue
Block a user