cipher aes-256-cbc
# Be the default gateway for clients.
push "redirect-gateway def1"
+# just sets up the ability to have client specific configs
+client-config-dir /etc/openvpn/client-config
EOF
+mkdir -p /etc/openvpn/client-config
+
if $dns; then
# Be the dns server for clients
gw=$(ip route | sed -rn 's/^default via .* dev (\S+).*/\1/p')
-sudo dd of=/etc/systemd/system/mynat.service <<EOF
+sudo dd of=/etc/systemd/system/vpnnat.service <<EOF
[Unit]
Description=Turns on nat iptables setting
ExecStop=/sbin/iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o $gw -j MASQUERADE
[Install]
-WantedBy=multi-user.target
+WantedBy=openvpn.service
EOF
systemctl daemon-reload # needed if the file was already there
-systemctl enable mynat.service
-systemctl start mynat.service
+systemctl enable vpnnat.service
+systemctl start vpnnat.service
systemctl restart openvpn@server