Last active
August 29, 2015 14:11
-
-
Save tianweidut/da371aed7760157029a0 to your computer and use it in GitHub Desktop.
iptables clear rules ignore docker
This file contains hidden or 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
| function clear(){ | |
| table=$1 | |
| chain=$2 | |
| iptables -t $table -L $chain -n --line-numbers -v | grep -iv 'docker' | grep '^[0-9]' | awk '{print $1}' | sort -nr | xargs -rl iptables -D $chain | |
| } | |
| clear filter FORWARD | |
| clear nat PREROUTING | |
| clear nat POSTROUTING | |
| clear nat OUTPUT | |
| iptables -t nat -L | grep "^Chain" | awk '{print $2}' | grep -ivE 'PREROUTING|DOCKER|POSTROUTING|OUTPUT' | xargs -rl iptables -t nat -X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment