Last active
November 13, 2015 15:03
-
-
Save vijaiaeroastro/52b5c2fae8b418cc9291 to your computer and use it in GitHub Desktop.
iptables rules cleaner
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 | |
####################################################### | |
# # | |
# Script to delete all iptables rules # | |
# @author : vijai@vijaikumar.in # | |
# # | |
####################################################### | |
# Make sure only root can run our script | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as sudo or root only!" 1>&2 | |
exit 1 | |
fi | |
if which ip6tables >/dev/null; then | |
echo "ip6tables does exist!!" | |
ip6tables --policy INPUT ACCEPT; | |
ip6tables --policy OUTPUT ACCEPT; | |
ip6tables --policy FORWARD ACCEPT; | |
ip6tables -Z; # zero counters | |
ip6tables -F; # flush (delete) rules | |
ip6tables -X; # delete all extra chains | |
echo "i cleared all the ip6tables rules for you :D" | |
else | |
echo "Sorry ip6tables doesn't exist!!" | |
fi | |
if which iptables >/dev/null; then | |
echo "iptables does exist!!" | |
iptables --policy INPUT ACCEPT; | |
iptables --policy OUTPUT ACCEPT; | |
iptables --policy FORWARD ACCEPT; | |
iptables -Z; # zero counters | |
iptables -F; # flush (delete) rules | |
iptables -X; # delete all extra chains | |
echo "i cleared all the iptables rules for you :D" | |
else | |
echo "Sorry iptables doesn't exist!!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment