Skip to content

Instantly share code, notes, and snippets.

@yalla
Created August 28, 2011 11:34
Show Gist options
  • Save yalla/1176565 to your computer and use it in GitHub Desktop.
Save yalla/1176565 to your computer and use it in GitHub Desktop.
Save and restore iptables rules
#!/bin/bash
case "$1" in
start)
iptables-save > /tmp/firewall-rules.backup
for i in nat filter mangle; do
iptables -t $i -F
done
# TODO: Add your Tor-rules *here*
;;
stop)
for i in nat filter mangle; do
iptables -t $i -F
done
iptables-restore < /tmp/firewall-rules.backup
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 [start|stop|restart]"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment