Skip to content

Instantly share code, notes, and snippets.

@mnebuerquo
Last active April 26, 2018 16:48
Show Gist options
  • Save mnebuerquo/34cb6f954e8533812b24e5042253f896 to your computer and use it in GitHub Desktop.
Save mnebuerquo/34cb6f954e8533812b24e5042253f896 to your computer and use it in GitHub Desktop.
Clear all rules from iptables without locking me out of the server
#!/bin/sh
# Clear out all iptables rules and make the changes persistent.
# first, find out if we're sudo
if [ $(id -u) -ne 0 ]; then
echo "Nope. Simon didn't say so.";
exit 1;
fi
iptables -L
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -F
iptables -t mangle -F
iptables -F
iptables -X
/etc/init.d/iptables-persistent save
iptables -L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment