summaryrefslogtreecommitdiffstats
path: root/makefu
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2017-08-07 16:28:21 +0200
committerlassulus <lassulus@lassul.us>2017-08-10 12:54:05 +0200
commitd2570114350b824a477df456f10eeec8ca14ef2c (patch)
treefc9a9e73df6848fe17eda1b086555af38e56d82f /makefu
parent7f4b909c29c94d8da973155119fd7e81570d28d8 (diff)
ma openvpn-server: init
for only a single client (smartphone) with psk
Diffstat (limited to 'makefu')
-rw-r--r--makefu/2configs/vpn/openvpn-server.nix111
-rw-r--r--makefu/2configs/vpn/vpngate.nix (renamed from makefu/2configs/openvpn/vpngate.nix)0
2 files changed, 111 insertions, 0 deletions
diff --git a/makefu/2configs/vpn/openvpn-server.nix b/makefu/2configs/vpn/openvpn-server.nix
new file mode 100644
index 000000000..1e7edbf78
--- /dev/null
+++ b/makefu/2configs/vpn/openvpn-server.nix
@@ -0,0 +1,111 @@
+{ config, pkgs, ... }:
+let
+ out-itf = config.makefu.server.primary-itf;
+ # generate via openvpn --genkey --secret static.key
+ client-key = (toString <secrets>) + "/openvpn-laptop.key";
+ # domain = "vpn.euer.krebsco.de";
+ domain = "gum.krebsco.de";
+ dev = "tun0";
+ port = 1194;
+ tcp-port = 3306;
+in {
+ boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
+ networking.nat = {
+ enable = true;
+ externalInterface = out-itf;
+ internalInterfaces = [ dev ];
+ };
+ networking.firewall.trustedInterfaces = [ dev ];
+ networking.firewall.allowedUDPPorts = [ port ];
+ environment.systemPackages = [ pkgs.openvpn ];
+ services.openvpn.servers.smartphone.config = ''
+ #user nobody
+ #group nobody
+
+ dev ${dev}
+ proto udp
+ ifconfig 10.8.0.1 10.8.0.2
+ secret ${client-key}
+ port ${toString port}
+ cipher AES-256-CBC
+ comp-lzo
+
+ keepalive 10 60
+ ping-timer-rem
+ persist-tun
+ persist-key
+ '';
+
+ environment.etc."openvpn/smartphone-client.ovpn" = {
+ text = ''
+ client
+ dev tun
+ remote "${domain}"
+ ifconfig 10.8.0.1 10.8.0.2
+ port ${toString port}
+
+ cipher AES-256-CBC
+ comp-lzo
+ keepalive 10 60
+ resolv-retry infinite
+ nobind
+ persist-key
+ persist-tun
+
+ secret [inline]
+
+ '';
+ mode = "700";
+ };
+ system.activationScripts.openvpn-addkey = ''
+ f="/etc/openvpn/smartphone-client.ovpn"
+ if ! grep -q '<secret>' $f; then
+ echo "appending secret key"
+ echo "<secret>" >> $f
+ cat ${client-key} >> $f
+ echo "</secret>" >> $f
+ fi
+ '';
+ #smartphone-tcp.config = ''
+ # user nobody
+ # group nobody
+
+ # dev ${dev}
+ # proto tcp
+ # ifconfig 10.8.0.1 10.8.0.3
+ # secret ${client-key}
+ # port tcp-port
+ # comp-lzo
+
+ # keepalive 10 60
+ # ping-timer-rem
+ # persist-tun
+ # persist-key
+ #'';
+ # TODO: forward via 443
+ # stream {
+ #
+ # map $ssl_preread_server_name $name {
+ # vpn1.app.com vpn1_backend;
+ # vpn2.app.com vpn2_backend;
+ # https.app.com https_backend;
+ # }
+ #
+ # upstream vpn1_backend {
+ # server 10.0.0.3:443;
+ # }
+ #
+ # upstream vpn2_backend {
+ # server 10.0.0.4:443;
+ # }
+ #
+ # upstream https_backend {
+ # server 10.0.0.5:443;
+ #
+ # server {
+ # listen 10.0.0.1:443;
+ # proxy_pass $name;
+ # ssl_preread on;
+ # }
+ # }
+}
diff --git a/makefu/2configs/openvpn/vpngate.nix b/makefu/2configs/vpn/vpngate.nix
index bf3101b19..bf3101b19 100644
--- a/makefu/2configs/openvpn/vpngate.nix
+++ b/makefu/2configs/vpn/vpngate.nix