Skip to content
Snippets Groups Projects
Commit 43c6406e authored by Bob Mottram's avatar Bob Mottram
Browse files

Use firewall function for vpn

parent 10da38da
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
# VPN functions
# https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-debian-8
# https://jamielinux.com/blog/force-all-network-traffic-through-openvpn-using-iptables/
# http://www.farrellf.com/projects/software/2016-05-04_Running_a_VPN_Server_with_OpenVPN_and_Stunnel/index_.php
#
# License
# =======
......
......@@ -111,6 +111,7 @@ function enable_ipv6 {
}
function firewall_disable_vpn {
firewall_remove VPN 1194
iptables -D INPUT -i ${FIREWALL_EIFACE} -m state --state NEW -p tcp --dport 1194 -j ACCEPT
iptables -D INPUT -i tun+ -j ACCEPT
iptables -D FORWARD -i tun+ -j ACCEPT
......@@ -119,11 +120,10 @@ function firewall_disable_vpn {
iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o ${FIREWALL_EIFACE} -j MASQUERADE
iptables -D OUTPUT -o tun+ -j ACCEPT
save_firewall_settings
sed -i '/VPN=/d' $FIREWALL_CONFIG
}
function firewall_enable_vpn {
firewall_add VPN 1194 tcp
iptables -A INPUT -i ${FIREWALL_EIFACE} -m state --state NEW -p tcp --dport 1194 -j ACCEPT
iptables -A INPUT -i tun+ -j ACCEPT
iptables -A FORWARD -i tun+ -j ACCEPT
......@@ -132,10 +132,6 @@ function firewall_enable_vpn {
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o ${FIREWALL_EIFACE} -j MASQUERADE
iptables -A OUTPUT -o tun+ -j ACCEPT
save_firewall_settings
if ! grep -q "VPN=" $FIREWALL_CONFIG; then
echo "VPN=1194" >> $FIREWALL_CONFIG
fi
}
function configure_firewall {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment