save iptables rules only when they change

main
glen 4 years ago
parent 06483f06c9
commit 4b9472fb75

@ -145,14 +145,18 @@ function configure_exit() {
sed -i 's#\#ifaddr=#ifaddr=172.16.0.1/16#g' /var/lib/lokinet/lokinet.ini sed -i 's#\#ifaddr=#ifaddr=172.16.0.1/16#g' /var/lib/lokinet/lokinet.ini
sed -i 's#\#paths=6#paths=8#g' /var/lib/lokinet/lokinet.ini sed -i 's#\#paths=6#paths=8#g' /var/lib/lokinet/lokinet.ini
sed -i 's#\#net.ipv4.ip_forward=1#net.ipv4.ip_forward = 1#g' /etc/sysctl.conf sed -i 's#\#net.ipv4.ip_forward=1#net.ipv4.ip_forward = 1#g' /etc/sysctl.conf
if [ -z $(grep "172.16.0.1/16" "/etc/iptables/rules.v4") ]; then iptables -t nat -A POSTROUTING -s 172.16.0.1/16 -o eth0 -j MASQUERADE; fi if grep -Fxq "172.16.0.1/16" /etc/iptables/rules.v4
then
echo -n "iptables entry already exists"
else
iptables -t nat -A POSTROUTING -s 172.16.0.1/16 -o eth0 -j MASQUERADE
iptables-save > /etc/iptables/rules.v4
fi
# iptables -t nat -A POSTROUTING -s 172.16.0.1/16 -o eth0 -j MASQUERADE # iptables -t nat -A POSTROUTING -s 172.16.0.1/16 -o eth0 -j MASQUERADE
iptables-save > /etc/iptables/rules.v4
sudo sysctl -p /etc/sysctl.conf sudo sysctl -p /etc/sysctl.conf
sudo systemctl restart lokinet sudo systemctl restart lokinet
#clean out installer files #clean out installer files
# sudo rm -r $exit_dir/installers || install_error "Unable to remove installers"
sudo rm -r /tmp/microexit || install_error "Unable to remove /tmp/microexit folder" sudo rm -r /tmp/microexit || install_error "Unable to remove /tmp/microexit folder"
#provide option to launch and display lokinet address #provide option to launch and display lokinet address

Loading…
Cancel
Save