Switch to systemd-networkd

This commit is contained in:
Quentin 2022-10-15 10:38:48 +02:00
parent 10b0840daa
commit c3a30aabab
Signed by untrusted user: quentin
GPG key ID: E9602264D639FF68

View file

@ -133,36 +133,38 @@ in
}) cfg.admin_accounts; }) cfg.admin_accounts;
# Configure network interfaces # Configure network interfaces
networking.interfaces = networking.useDHCP = false;
let ip4config = { networking.useNetworkd = true;
useDHCP = false; systemd.network.networks = {
ipv4.addresses = [ "10-uplink" = {
matchConfig = {
# We could preprend "en* eth*" to match all ethernet interfaces
Name = "${cfg.network_interface}";
};
networkConfig = {
IPv6AcceptRA = false;
LinkLocalAddressing = "no";
};
address = [
"${cfg.lan_ip}/${toString cfg.lan_ip_prefix_length}"
"${cfg.ipv6}/${toString cfg.ipv6_prefix_length}"
];
routes = [
{ {
address = cfg.lan_ip; routeConfig = {
prefixLength = cfg.lan_ip_prefix_length; Gateway = cfg.lan_default_gateway;
# GatewayOnLink - Takes a boolean. If set to true, the kernel does not have to check if the gateway is reachable directly by the current machine (i.e., attached to the local network), so that we can insert the route in the kernel table without it being complained about. Defaults to "no".
GatewayOnLink = true;
};
}
{
routeConfig = {
Gateway = cfg.ipv6_default_gateway;
GatewayOnLink = true;
};
} }
]; ];
}; };
ip6config = {
tempAddress = "disabled";
ipv6.addresses = [
{
address = cfg.ipv6;
prefixLength = cfg.ipv6_prefix_length;
}
];
};
in
(attrsets.setAttrByPath [ cfg.network_interface ] (ip4config // ip6config));
networking.defaultGateway = {
address = cfg.lan_default_gateway;
interface = cfg.network_interface;
};
networking.defaultGateway6 = {
address = cfg.ipv6_default_gateway;
interface = cfg.network_interface;
}; };
# Configure Unbound DNS to redirect to Consul queries under .consul # Configure Unbound DNS to redirect to Consul queries under .consul