-
-
Save amdprophet/07b7466e420aa92e5dc16d7bc30fcaac to your computer and use it in GitHub Desktop.
Reset iptables
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
#!/usr/bin/env bash | |
set -eu | |
declare -A chains=( | |
[filter]=INPUT:FORWARD:OUTPUT | |
[raw]=PREROUTING:OUTPUT | |
[mangle]=PREROUTING:INPUT:FORWARD:OUTPUT:POSTROUTING | |
[security]=INPUT:FORWARD:OUTPUT | |
[nat]=PREROUTING:INPUT:OUTPUT:POSTROUTING | |
) | |
for table in "${!chains[@]}"; do | |
echo "${chains[$table]}" | tr : $"\n" | while IFS= read -r; do | |
iptables -t "$table" -P "$REPLY" ACCEPT | |
done | |
iptables -t "$table" -F | |
iptables -t "$table" -X | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment