fruitbasket/hosts/quitte/network.nix

99 lines
2.3 KiB
Nix
Raw Normal View History

2024-02-03 20:02:15 +01:00
{ config, lib, ... }:
2022-12-09 16:18:57 +01:00
let
wireguard_port = 51820;
in
{
sops.secrets = {
"wg-fsr" = {
owner = config.users.users.systemd-network.name;
};
};
networking = {
2024-02-03 20:02:15 +01:00
# portunus module does weird things to this, so we force it to some sane values
hosts = {
2024-02-03 20:03:45 +01:00
"127.0.0.1" = lib.mkForce [ "quitte.ifsr.de" "quitte" ];
"::1" = lib.mkForce [ "quitte.ifsr.de" "quitte" ];
2024-02-03 20:02:15 +01:00
};
2022-12-09 16:18:57 +01:00
hostId = "a71c81fc";
domain = "ifsr.de";
hostName = "quitte";
rDNS = config.networking.fqdn;
2022-12-09 16:18:57 +01:00
enableIPv6 = true;
useDHCP = true;
interfaces.ens18.useDHCP = true;
2022-12-09 16:18:57 +01:00
useNetworkd = true;
2023-10-23 11:59:12 +02:00
nftables.enable = true;
2022-12-09 16:18:57 +01:00
firewall = {
allowedUDPPorts = [ wireguard_port ];
logRefusedConnections = false;
};
2022-12-09 16:18:57 +01:00
wireguard.enable = true;
};
services.resolved = {
enable = true;
2023-02-15 13:34:14 +01:00
#dnssec = "false";
2022-12-09 16:18:57 +01:00
fallbackDns = [ "1.1.1.1" ];
};
# workaround for networkd waiting for shit
systemd.services.systemd-networkd-wait-online.serviceConfig.ExecStart = [
"" # clear old command
"${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
];
systemd.network = {
enable = true;
# Interfaces on the machine
2024-01-29 16:23:56 +01:00
networks."10-wired-default" = {
matchConfig.Name = "ens18";
2023-02-15 13:34:14 +01:00
address = [ "141.30.30.169/25" ];
routes = [
2023-02-15 13:35:32 +01:00
{
routeConfig.Gateway = "141.30.30.129";
}
2023-02-15 13:34:14 +01:00
];
2022-12-09 16:18:57 +01:00
networkConfig = {
DNS = "141.30.1.1";
#IPv6AcceptRA = true;
};
};
# defining network device for wireguard connections
netdevs."fsr-wg" = {
netdevConfig = {
Kind = "wireguard";
Name = "fsr-wg";
Description = "fsr enterprise wireguard";
};
wireguardConfig = {
PrivateKeyFile = config.sops.secrets."wg-fsr".path;
ListenPort = wireguard_port;
};
wireguardPeers = [
{
# tassilo
wireguardPeerConfig = {
PublicKey = "vgo3le9xrFsIbbDZsAhQZpIlX+TuWjfEyUcwkoqUl2Y=";
AllowedIPs = [ "10.66.66.100/32" ];
PersistentKeepalive = 25;
};
}
];
};
# fsr wireguard server
networks."fsr-wg" = {
matchConfig.Name = "fsr-wg";
networkConfig = {
Address = "10.66.66.1/24";
IPForward = "ipv4";
};
};
};
}