nixos-config/hosts/thinkpad/modules/networks/default.nix

143 lines
3.6 KiB
Nix
Raw Normal View History

{ config, ... }:
{
imports = [ ./uni.nix ];
2022-12-30 11:02:10 +01:00
sops.secrets = {
"wireless-env" = { };
"wireguard/dorm/private" = {
owner = config.users.users.systemd-network.name;
};
"wireguard/dorm/preshared" = {
owner = config.users.users.systemd-network.name;
};
2022-12-30 11:02:10 +01:00
};
services.resolved = {
fallbackDns = [
"9.9.9.9"
"149.112.112.112"
"2620:fe::fe"
"2620:fe::9"
];
# allow downgrade since fritzbox at home doesn't support it (yet?)
dnssec = "allow-downgrade";
};
2023-04-12 22:09:46 +02:00
networking = {
useNetworkd = true;
hostName = "thinkpad";
2023-08-02 18:04:26 +02:00
hostId = "d8d34032";
2023-04-12 15:05:15 +02:00
enableIPv6 = true;
firewall.allowedTCPPorts = [ 24727 ];
wireless = {
enable = true;
userControlled.enable = true;
environmentFile = config.sops.secrets."wireless-env".path;
networks = {
"@HOME_SSID@" = {
psk = "@HOME_PSK@";
authProtocols = [ "WPA-PSK" ];
};
"@DORM_SSID@" = {
psk = "@DORM_PSK@";
authProtocols = [ "WPA-PSK" ];
};
"@PIXEL_SSID@" = {
psk = "@PIXEL_PSK@";
authProtocols = [ "WPA-PSK" ];
};
};
};
};
systemd.network = {
enable = true;
2023-01-15 14:27:49 +01:00
networks."10-loopback" = {
matchConfig.Name = "lo";
2023-01-23 23:35:44 +01:00
linkConfig.RequiredForOnline = false;
2023-01-15 14:27:49 +01:00
};
networks."10-wired" = {
matchConfig.Name = "enp0s31f6";
2023-02-14 19:49:31 +01:00
linkConfig.RequiredForOnline = false;
2023-01-15 14:27:49 +01:00
networkConfig = {
DHCP = "yes";
2023-05-30 17:33:15 +02:00
IPv6AcceptRA = "yes";
IPv6PrivacyExtensions = "yes";
};
2023-01-15 14:27:49 +01:00
dhcpV4Config = {
RouteMetric = 10;
};
};
2023-01-15 14:58:38 +01:00
networks."10-wireless-home" = {
matchConfig = {
Name = "wlp9s0";
2023-04-06 11:00:53 +02:00
SSID = "Smoerrebroed";
2023-01-15 14:58:38 +01:00
};
networkConfig = {
DHCP = "yes";
IgnoreCarrierLoss = "3s";
IPv6AcceptRA = "yes";
IPv6PrivacyExtensions = "yes";
2023-01-15 14:58:38 +01:00
};
dhcpV4Config = {
RouteMetric = 20;
};
routes = [
# Route to the Model train network via raspi
{ routeConfig = { Gateway = "192.168.178.63"; Destination = "192.168.179.0/24"; }; }
];
};
networks."15-wireless-default" = {
2023-01-15 14:27:49 +01:00
matchConfig.Name = "wlp9s0";
2023-02-14 19:49:31 +01:00
linkConfig.RequiredForOnline = false;
2023-01-15 14:27:49 +01:00
networkConfig = {
DHCP = "yes";
IgnoreCarrierLoss = "3s";
2023-04-12 15:05:15 +02:00
IPv6AcceptRA = "yes";
2023-05-30 17:33:15 +02:00
IPv6PrivacyExtensions = "yes";
};
2023-01-15 14:27:49 +01:00
dhcpV4Config = {
RouteMetric = 20;
2022-12-30 11:02:10 +01:00
};
2023-04-12 15:05:15 +02:00
2022-12-30 11:02:10 +01:00
};
# some wireguard interfaces
2023-01-15 14:27:49 +01:00
netdevs."30-dorm" = {
netdevConfig = {
Kind = "wireguard";
Name = "dorm";
Description = "WireGuard to my Dorm Infra";
};
wireguardConfig = {
PrivateKeyFile = config.sops.secrets."wireguard/dorm/private".path;
ListenPort = 51820;
};
wireguardPeers = [
{
wireguardPeerConfig = {
PublicKey = "vUmworuJFHjB4KUdkucQ+nzqO2ysARLomq4UuK1n430=";
PresharedKeyFile = config.sops.secrets."wireguard/dorm/preshared".path;
Endpoint = "dorm.vpn.rfive.de:51820";
AllowedIPs = "10.10.10.0/24, 192.168.10.0/24"; # seems to be broken, has no effect on routes
};
}
];
};
networks."30-dorm" = {
matchConfig.Name = "dorm";
2023-05-05 23:43:40 +02:00
networkConfig = {
DNS = "192.168.10.1";
};
2023-01-16 16:55:17 +01:00
addresses = [
{
addressConfig = {
Address = "10.10.10.3/24";
RouteMetric = 30;
};
}
];
2023-01-15 14:27:49 +01:00
routes = [
2023-01-16 16:55:17 +01:00
{ routeConfig = { Gateway = "0.0.0.0"; Destination = "192.168.10.0/24"; Metric = 30; }; }
2023-01-15 14:27:49 +01:00
];
};
};
}