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

111 lines
2.6 KiB
Nix
Raw Normal View History

{ config, pkgs, ... }:
2023-04-12 17:21:24 +02:00
{
2023-11-16 15:08:13 +01:00
age.secrets = {
2023-07-30 19:41:51 +02:00
"wireguard/dorm/private" = {
2023-11-16 15:08:13 +01:00
file = ../../../../secrets/falkenstein/wireguard/dorm/private.age;
2023-07-30 19:41:51 +02:00
owner = config.users.users.systemd-network.name;
};
"wireguard/dorm/preshared" = {
2023-11-16 15:08:13 +01:00
file = ../../../../secrets/falkenstein/wireguard/dorm/preshared.age;
2023-07-30 19:41:51 +02:00
owner = config.users.users.systemd-network.name;
};
2023-11-16 15:08:13 +01:00
2023-07-30 19:41:51 +02:00
};
environment.systemPackages = with pkgs; [
mtr
inetutils
dnsutils
wireguard-tools
];
2023-04-12 17:21:24 +02:00
networking = {
2023-11-20 22:46:51 +01:00
hostName = "falkenstein";
2023-10-26 12:12:45 +02:00
nftables.enable = true;
2023-09-19 13:47:08 +02:00
domain = "rfive.de";
2023-04-12 17:21:24 +02:00
useNetworkd = true;
enableIPv6 = true;
2023-12-12 17:44:28 +01:00
firewall = {
allowedUDPPorts = [ 51820 ];
2023-12-12 17:44:28 +01:00
extraInputRules = ''
ip saddr 192.168.0.0/16 tcp dport 19531 accept comment "Allow journald gateway access from local networks"
'';
};
2023-04-12 17:21:24 +02:00
};
services.resolved = {
dnssec = "true";
fallbackDns = [
"9.9.9.9"
"149.112.112.112"
"2620:fe::fe"
"2620:fe::9"
];
};
2023-04-12 17:21:24 +02:00
systemd.network = {
enable = true;
2023-12-23 17:30:24 +01:00
config = {
networkConfig = {
SpeedMeter = true;
};
};
2023-04-12 17:21:24 +02:00
networks."10-loopback" = {
matchConfig.Name = "lo";
};
networks."10-wired" = {
matchConfig.Name = "ens3";
2023-12-27 22:22:42 +01:00
dns = [
"2a01:4ff:ff00::add:1"
"2a01:4ff:ff00::add:2"
];
2023-04-12 17:21:24 +02:00
networkConfig = {
DHCP = "ipv4";
2023-04-12 20:47:00 +02:00
IPv6AcceptRA = "yes";
Address = "2a01:4f8:c012:49de::1/64";
Gateway = "fe80::1";
2023-04-12 17:21:24 +02:00
};
};
2023-07-30 19:41:51 +02:00
netdevs."30-dorm" = {
netdevConfig = {
Kind = "wireguard";
2023-10-22 15:45:30 +02:00
Name = "wg0";
2023-07-30 19:41:51 +02:00
};
wireguardConfig = {
2023-11-16 15:08:13 +01:00
PrivateKeyFile = config.age.secrets."wireguard/dorm/private".path;
2023-07-30 19:41:51 +02:00
ListenPort = 51820;
2023-12-23 17:30:24 +01:00
RouteTable = "main";
RouteMetric = 30;
2023-07-30 19:41:51 +02:00
};
wireguardPeers = [
{
wireguardPeerConfig = {
2023-10-22 15:45:30 +02:00
PublicKey = "Z5lwwHTCDr6OF4lfaCdSHNveunOn4RzuOQeyB+El9mQ=";
2023-11-16 15:08:13 +01:00
PresharedKeyFile = config.age.secrets."wireguard/dorm/preshared".path;
2024-03-09 12:40:02 +01:00
Endpoint = "nuc.rfive.de:51820";
2023-10-22 15:45:30 +02:00
AllowedIPs = "192.168.42.0/24, 192.168.43.0/24";
2023-07-30 19:41:51 +02:00
};
}
];
};
networks."30-dorm" = {
2023-10-22 15:45:30 +02:00
matchConfig.Name = "wg0";
2024-04-26 10:37:13 +02:00
addresses = [
{
addressConfig = {
Address = "192.168.43.4/24";
AddPrefixRoute = false;
};
}
];
2023-07-30 19:41:51 +02:00
networkConfig = {
DNS = "192.168.43.1";
2024-04-18 19:49:10 +02:00
Domains = [
"~vpn.rfive.de"
"~42.168.192.in-addr.arpa"
"~43.168.192.in-addr.arpa"
];
DNSSEC = false;
2023-12-23 17:30:24 +01:00
BindCarrier = [ "ens3" ];
2023-07-30 19:41:51 +02:00
};
};
2023-04-12 17:21:24 +02:00
};
}