zion/modules/networking.nix

82 lines
1.6 KiB
Nix
Raw Normal View History

2019-11-06 23:04:16 +01:00
{ config, pkgs, lib, ... }:
2020-09-24 16:13:02 +02:00
let password = builtins.readFile /var/lib/ddclient/token;
2020-06-09 21:53:20 +02:00
in {
2019-11-06 23:04:16 +01:00
2020-09-02 18:44:31 +02:00
environment.systemPackages = with pkgs; [ mbuffer ];
2019-11-06 23:04:16 +01:00
2020-02-21 12:25:43 +01:00
# Enable zeroconf
services.avahi = {
enable = true;
nssmdns = true;
publish = {
enable = true;
userServices = true;
2020-06-09 21:53:20 +02:00
domain = true;
workstation = true;
2020-02-21 12:25:43 +01:00
};
2020-04-17 00:47:17 +02:00
reflector = true;
2020-02-21 12:25:43 +01:00
};
2019-11-06 23:04:16 +01:00
# Dynamic DNS configuration
services.ddclient = {
enable = true;
quiet = true;
2019-11-10 17:47:46 +01:00
protocol = "duckdns";
domains = [ "coolneng.duckdns.org" ];
inherit password;
2019-11-06 23:04:16 +01:00
};
# Firewall configuration
networking.firewall = {
allowedTCPPorts = [
631 # Cups
6566 # SANE
80
443
];
2020-02-21 12:25:43 +01:00
allowedUDPPorts = [
1194 # Wireguard
2020-02-21 12:25:43 +01:00
];
2019-11-06 23:04:16 +01:00
autoLoadConntrackHelpers = true;
connectionTrackingModules = [ "sane" ];
2020-02-21 12:25:43 +01:00
extraCommands = ''
2020-06-09 21:53:20 +02:00
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
'';
2019-11-06 23:04:16 +01:00
};
2019-11-11 14:30:45 +01:00
2019-12-09 10:04:41 +01:00
# Disable IPv6
networking.enableIPv6 = false;
2020-02-21 12:25:43 +01:00
# Enable NAT for wireguard
networking.nat = {
enable = true;
externalInterface = "eth0";
internalInterfaces = [ "wg0" ];
};
# Wireguard setup
networking.wireguard.interfaces = {
wg0 = {
ips = [ "10.8.0.1/24" ];
listenPort = 1194;
2020-02-21 12:25:43 +01:00
privateKeyFile = "/home/coolneng/.wg/keys/privatekey";
peers = [
2020-06-09 21:53:20 +02:00
# Panacea
2020-02-21 12:25:43 +01:00
{
2020-06-09 21:53:20 +02:00
publicKey = "XMkTztU2Y8hw6Fu/2o4Gszij+EmNacvFMXuZyHS1n38=";
2020-02-21 12:25:43 +01:00
allowedIPs = [ "10.8.0.2/32" ];
}
2020-09-24 16:13:02 +02:00
# Prosorinos
{
publicKey = "ipr+95jPZaCwEQybLsN5njxENMrPFbUUKf8CTNvGsDA=";
2020-09-24 21:56:25 +02:00
allowedIPs = [ "10.8.0.3/32" ];
2020-09-24 16:13:02 +02:00
}
2020-02-21 12:25:43 +01:00
];
};
};
2019-11-06 23:04:16 +01:00
}