mirror of
https://github.com/pivpn/pivpn.git
synced 2025-05-07 16:34:10 +02:00
Handle older UFW version from Jessie
This commit is contained in:
parent
e8883238f5
commit
e6a13cc65e
3 changed files with 52 additions and 14 deletions
|
@ -971,8 +971,21 @@ confNetwork() {
|
|||
$SUDO sed "/delete these required/i *nat\n:POSTROUTING ACCEPT [0:0]\n-I POSTROUTING -s 10.8.0.0/24 -o $IPv4dev -j MASQUERADE\nCOMMIT\n" -i /etc/ufw/before.rules
|
||||
# Insert rules at the beginning of the chain (in case there are other rules that may drop the traffic)
|
||||
$SUDO ufw insert 1 allow "$PORT"/"$PROTO" >/dev/null
|
||||
# Don't forward everything, just the traffic originated from the VPN subnet
|
||||
$SUDO ufw route insert 1 allow in on tun0 from 10.8.0.0/24 out on "$IPv4dev" to any >/dev/null
|
||||
|
||||
# https://askubuntu.com/a/712202
|
||||
INSTALLED_UFW=$(dpkg-query --showformat='${Version}' --show ufw)
|
||||
MINIMUM_UFW=0.34
|
||||
|
||||
if $SUDO dpkg --compare-versions "$INSTALLED_UFW" ge "$MINIMUM_UFW"; then
|
||||
# Don't forward everything, just the traffic originated from the VPN subnet
|
||||
$SUDO ufw route insert 1 allow in on tun0 from 10.8.0.0/24 out on "$IPv4dev" to any >/dev/null
|
||||
echo 0 > /tmp/OLD_UFW
|
||||
else
|
||||
# This ufw version does not support route command, fallback to policy change
|
||||
$SUDO sed -i "s/\(DEFAULT_FORWARD_POLICY=\).*/\1\"ACCEPT\"/" /etc/default/ufw
|
||||
echo 1 > /tmp/OLD_UFW
|
||||
fi
|
||||
|
||||
$SUDO ufw reload >/dev/null
|
||||
echo "::: UFW configuration completed."
|
||||
fi
|
||||
|
@ -1035,6 +1048,7 @@ confNetwork() {
|
|||
echo "$FORWARD_CHAIN_EDITED" > /tmp/FORWARD_CHAIN_EDITED
|
||||
|
||||
$SUDO cp /tmp/noUFW /etc/pivpn/NO_UFW
|
||||
$SUDO cp /tmp/OLD_UFW /etc/pivpn/OLD_UFW
|
||||
$SUDO cp /tmp/INPUT_CHAIN_EDITED /etc/pivpn/INPUT_CHAIN_EDITED
|
||||
$SUDO cp /tmp/FORWARD_CHAIN_EDITED /etc/pivpn/FORWARD_CHAIN_EDITED
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue