1
1
mirror of https://github.com/namibia/openvpn-install.git synced 2024-06-07 05:50:46 +00:00

Fix iptables rules on reboot for some OS

Thanks a lot to Nyr for the fix : a31aaf82f3

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
This commit is contained in:
Angristan 2017-06-25 22:01:05 +02:00 committed by GitHub
parent 10351305e3
commit ac203dd5ee

View File

@ -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