This commit is contained in:
Angristan 2018-07-06 21:57:39 +00:00 committed by GitHub
commit 6f3f2543b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -583,6 +583,22 @@ verb 3" >> /etc/openvpn/server.conf
fi fi
# Avoid an unneeded reboot # Avoid an unneeded reboot
echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_forward
# Allo forward on Ubuntu with UFW
if [[ $(lsb_release -si) == "Ubuntu" ]];then
# If the DEFAULT_FORWARD_POLICY is not accept
if ! grep -qe '^DEFAULT_FORWARD_POLICY=\"ACCEPT\"' /etc/default/ufw;then
# If the there is an uncommented DEFAULT_FORWARD_POLICY line
if ! grep -qe '^DEFAULT_FORWARD_POLICY' /etc/default/ufw;then
# Set it to ACCEPT
sed -i 's|^DEFAULT_FORWARD_POLICY=\".*\"|DEFAULT_FORWARD_POLICY=\"ACCEPT\"|' /etc/default/ufw
else
# Just add the correct line
echo 'DEFAULT_FORWARD_POLICY="ACCEPT"' >> /etc/default/ufw
fi
fi
fi
# Set NAT for the VPN subnet # Set NAT for the VPN subnet
iptables -t nat -A POSTROUTING -o $NIC -s 10.8.0.0/24 -j MASQUERADE iptables -t nat -A POSTROUTING -o $NIC -s 10.8.0.0/24 -j MASQUERADE
# Save persitent iptables rules # Save persitent iptables rules