From ac203dd5eef586fb4a1c5db2fb0ca602d91edd32 Mon Sep 17 00:00:00 2001 From: Angristan Date: Sun, 25 Jun 2017 22:01:05 +0200 Subject: [PATCH] Fix iptables rules on reboot for some OS Thanks a lot to Nyr for the fix : https://github.com/Nyr/openvpn-install/commit/a31aaf82f3664e5854c617752a5493011ede731f Fixes https://github.com/Angristan/OpenVPN-install/issues/6. On Ubuntu 17.04, 16.10 and Debian 9, the iptables rules were not applied because of rc.local --- openvpn-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openvpn-install.sh b/openvpn-install.sh index ee7e3ac..2b0e68f 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -490,6 +490,12 @@ verb 3" >> /etc/openvpn/server.conf fi # Avoid an unneeded reboot echo 1 > /proc/sys/net/ipv4/ip_forward + # Needed to use rc.local with some systemd distros + if [[ "$OS" = 'debian' && ! -e $RCLOCAL ]]; then + echo '#!/bin/sh -e + exit 0' > $RCLOCAL + fi + chmod +x $RCLOCAL # Set NAT for the VPN subnet iptables -t nat -A POSTROUTING -o $NIC -s 10.8.0.0/24 -j MASQUERADE sed -i "1 a\iptables -t nat -A POSTROUTING -o $NIC -s 10.8.0.0/24 -j MASQUERADE" $RCLOCAL