1 { pkgs, lib, inputs, hostName, ... }:
3 domain = "sourcephile.fr";
5 iface = "neb-sourcephile";
8 environment.systemPackages = with pkgs; [ nebula ];
9 systemd.services."nebula@${domain}".serviceConfig.LoadCredentialEncrypted = [
10 "${hostName}.key:${nebula/. + "/${hostName}.key.cred"}"
12 services.nebula.networks.${domain} = {
14 ca = inputs.self + "/share/nebula/${domain}/ca.crt";
15 cert = inputs.self + "/share/nebula/${domain}/${hostName}.crt";
16 key = "/run/credentials/nebula@${domain}.service/${hostName}.key";
17 listen = { host = "0.0.0.0"; port = port; };
22 #"10.0.0.1" = [ "mermet.${domain}:10001" ];
23 "10.0.0.2" = [ "losurdo.${domain}:10002" ];
32 outbound = [{ port = "any"; proto = "any"; host = "any"; }];
33 inbound = [{ port = "any"; proto = "any"; host = "any"; }];
36 networking.nftables.ruleset = ''
39 udp dport ${toString port} counter accept comment "Nebula ${domain}"
42 udp sport ${toString port} counter accept comment "Nebula ${domain}"
44 chain input-${iface} {
45 tcp dport ssh counter accept comment "SSH"
46 udp dport 60000-60100 counter accept comment "Mosh"
48 chain output-${iface} {
49 tcp dport ssh counter accept comment "SSH"
50 udp dport 60000-60100 counter accept comment "Mosh"
54 iifname ${iface} jump input-${iface}
55 iifname ${iface} log level warn prefix "input-${iface}: " counter drop
58 oifname ${iface} jump output-${iface}
59 oifname ${iface} log level warn prefix "output-${iface}: " counter drop
64 services.fail2ban.ignoreIP = lib.concatMap
65 (host: host.peer.allowedIPs)
66 (lib.attrValues peers);
67 networking.networkmanager.unmanaged = [ wgIface ];