#!/bin/sh #https://help.ubuntu.com/community/IptablesHowTo #install # sudo cp 01firewall /etc/NetworkManager/dispatcher.d # sudo chown root:root /etc/NetworkManager/dispatcher.d/01firewall # sudo chmod 755 /etc/NetworkManager/dispatcher.d/01firewall if [ -x /usr/bin/logger ]; then LOGGER="/usr/bin/logger -s -p daemon.info -t FirewallHandler" else LOGGER=echo fi ${LOGGER} "/etc/NetworkManager/dispatcher.d/01firewall $1 $2" case "$2" in up) if [ ! -r /etc/iptables.rules ]; then ${LOGGER} "No iptables rules exist to restore." return fi if [ ! -x /sbin/iptables-restore ]; then ${LOGGER} "No program exists to restore iptables rules." return fi ${LOGGER} "Restoring iptables rules" # /sbin/iptables-restore -c < /etc/iptables.rules /sbin/iptables-restore < /etc/iptables.rules ;; down) if [ ! -x /sbin/iptables-save ]; then ${LOGGER} "No program exists to save iptables rules." return fi # ${LOGGER} "Saving iptables rules." # /sbin/iptables-save -c > /etc/iptables.rules ${LOGGER} "Not modifying /etc/iptables.rules" ;; *) ${LOGGER} "Unrecognized command \"$2\"." ;; esac