mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-20 03:40:17 +00:00
Use ${pivpnNET} and ${subnetClass} when adding ufw nat rules
This commit is contained in:
parent
d022cafa25
commit
c20e7d2150
1 changed files with 3 additions and 3 deletions
|
@ -1432,10 +1432,10 @@ confNetwork(){
|
||||||
fi
|
fi
|
||||||
### If there is already a "*nat" section just add our POSTROUTING MASQUERADE
|
### If there is already a "*nat" section just add our POSTROUTING MASQUERADE
|
||||||
if $SUDO grep -q "*nat" /etc/ufw/before.rules; then
|
if $SUDO grep -q "*nat" /etc/ufw/before.rules; then
|
||||||
$SUDO sed "/^*nat/{n;s/\(:POSTROUTING ACCEPT .*\)/\1\n-I POSTROUTING -s ${pivpnNET}\/24 -o ${IPv4dev} -j MASQUERADE/}" -i /etc/ufw/before.rules
|
$SUDO sed "/^*nat/{n;s/\(:POSTROUTING ACCEPT .*\)/\1\n-I POSTROUTING -s ${pivpnNET}\/${subnetClass} -o ${IPv4dev} -j MASQUERADE/}" -i /etc/ufw/before.rules
|
||||||
else
|
else
|
||||||
$SUDO sed "/delete these required/i *nat\n:POSTROUTING ACCEPT [0:0]\n-I POSTROUTING -s ${pivpnNET}\/${subnetClass} -o ${IPv4dev} -j MASQUERADE\nCOMMIT\n" -i /etc/ufw/before.rules
|
$SUDO sed "/delete these required/i *nat\n:POSTROUTING ACCEPT [0:0]\n-I POSTROUTING -s ${pivpnNET}\/${subnetClass} -o ${IPv4dev} -j MASQUERADE\nCOMMIT\n" -i /etc/ufw/before.rules
|
||||||
fi
|
fi
|
||||||
# Insert rules at the beginning of the chain (in case there are other rules that may drop the traffic)
|
# Insert rules at the beginning of the chain (in case there are other rules that may drop the traffic)
|
||||||
$SUDO ufw insert 1 allow "${pivpnPORT}"/"${pivpnPROTO}" >/dev/null
|
$SUDO ufw insert 1 allow "${pivpnPORT}"/"${pivpnPROTO}" >/dev/null
|
||||||
$SUDO ufw route insert 1 allow in on "${pivpnDEV}" from "${pivpnNET}/${subnetClass}" out on "${IPv4dev}" to any >/dev/null
|
$SUDO ufw route insert 1 allow in on "${pivpnDEV}" from "${pivpnNET}/${subnetClass}" out on "${IPv4dev}" to any >/dev/null
|
||||||
|
|
Loading…
Reference in a new issue