2019-11-06 23:04:16 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2019-12-09 05:57:30 +01:00
|
|
|
|
|
|
|
let password = builtins.readFile /var/lib/ddclient/token;
|
|
|
|
|
|
|
|
in
|
2019-11-06 23:04:16 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
2020-03-29 06:21:19 +02:00
|
|
|
avahi
|
|
|
|
ddclient
|
2020-02-21 12:25:43 +01:00
|
|
|
wireguard
|
|
|
|
wireguard-tools
|
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;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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" ];
|
2019-12-09 05:57:30 +01:00
|
|
|
inherit password;
|
2019-11-06 23:04:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# Firewall configuration
|
|
|
|
networking.firewall = {
|
2019-11-11 03:29:00 +01:00
|
|
|
allowedTCPPorts = [
|
|
|
|
631 # Cups
|
|
|
|
6566 # SANE
|
|
|
|
80
|
|
|
|
443
|
|
|
|
];
|
2020-02-21 12:25:43 +01:00
|
|
|
allowedUDPPorts = [
|
2020-03-05 09:01:54 +01:00
|
|
|
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 = ''
|
|
|
|
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" ];
|
2020-03-05 09:01:54 +01:00
|
|
|
listenPort = 1194;
|
2020-02-21 12:25:43 +01:00
|
|
|
privateKeyFile = "/home/coolneng/.wg/keys/privatekey";
|
|
|
|
peers = [
|
|
|
|
# Monolith
|
|
|
|
{
|
|
|
|
publicKey = "ka9a/VB49XMtrMw/ZJmZHThfk2Y5D/8wErLPtN+KvHE=";
|
|
|
|
allowedIPs = [ "10.8.0.2/32" ];
|
|
|
|
}
|
|
|
|
# Roamer
|
|
|
|
{
|
|
|
|
publicKey = "gS5VIUFL74kTs3zxVNT/ijWyOjeAFLEqWynD0Pefh1o=";
|
|
|
|
allowedIPs = [ "10.8.0.3/32" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-11-06 23:04:16 +01:00
|
|
|
}
|
|
|
|
|