ma wireguard/server: clean up

This commit is contained in:
makefu 2022-06-06 21:25:30 +02:00
parent 6630d29d44
commit e8eeaace1a
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -1,26 +1,36 @@
{ config, ... }:
{ config,pkgs, ... }:
let
ext-if = config.makefu.server.primary-itf;
in { # wireguard server
# opkg install wireguard luci-proto-wireguard
# TODO: networking.nat
# boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
# conf.all.proxy_arp =1
networking.firewall = {
allowedUDPPorts = [ 51820 ];
extraCommands = ''
iptables -t nat -A POSTROUTING -s 10.244.0.0/24 -o ${ext-if} -j MASQUERADE
'';
};
networking.nat = {
enable = true;
#externalIP = "144.76.26.247";
#internalIPs = [ "10.244.0.0/24" ];
externalInterface = ext-if;
internalInterfaces = [ "wg0" ];
};
networking.wireguard.interfaces.wg0 = {
ips = [ "10.244.0.1/24" ];
listenPort = 51820;
privateKeyFile = (toString <secrets>) + "/wireguard.key";
allowedIPsAsRoutes = true;
# allowedIPsAsRoutes = true;
postSetup = ''
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.244.0.0/24 -o ${ext-if} -j MASQUERADE
'';
# This undoes the above command
postShutdown = ''
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.244.0.0/24 -o ${ext-if} -j MASQUERADE
'';
peers = [
{
# x