Last active
November 12, 2019 03:47
-
-
Save adamelliotfields/4eb1924cade9d3034a701a7bafdc056c to your computer and use it in GitHub Desktop.
Reset iptables / ip6tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ "$(id -u)" != '0' ]; then | |
SUDO=sudo | |
fi | |
policies=( | |
'INPUT' | |
'OUTPUT' | |
'FORWARD' | |
) | |
options=( | |
'-Z' | |
'-F' | |
'-X' | |
) | |
for policy in "${policies[@]}"; do | |
${SUDO} iptables -P "$policy" ACCEPT | |
${SUDO} ip6tables -P "$policy" ACCEPT | |
done | |
for option in "${options[@]}"; do | |
${SUDO} iptables "$option" | |
${SUDO} ip6tables "$option" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment