Skip to content

Commit

Permalink
Fix #255
Browse files Browse the repository at this point in the history
Ubuntu no longer includes the rc.local file, so iptables weren’t
applied after a system reboot.
  • Loading branch information
Nyr committed Jan 29, 2017
1 parent 971474e commit a31aaf8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then
OS=centos
GROUPNAME=nobody
RCLOCAL='/etc/rc.d/rc.local'
# Needed for CentOS 7
chmod +x /etc/rc.d/rc.local
else
echo "Looks like you aren't running this installer on a Debian, Ubuntu or CentOS system"
exit 5
Expand Down Expand Up @@ -311,6 +309,12 @@ crl-verify crl.pem" >> /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 -s 10.8.0.0/24 -j SNAT --to $IP
sed -i "1 a\iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to $IP" $RCLOCAL
Expand Down

0 comments on commit a31aaf8

Please sign in to comment.