Skip to content

Instantly share code, notes, and snippets.

@MattMcMurray
Created June 16, 2017 14:57
Show Gist options
  • Save MattMcMurray/3051ffd389e18dbddbe52330cc83070c to your computer and use it in GitHub Desktop.
Save MattMcMurray/3051ffd389e18dbddbe52330cc83070c to your computer and use it in GitHub Desktop.
Reset iptables
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules
# First, set the default policies for each of the built-in chains to ACCEPT.
# The main reason to do this is to ensure that you won't be locked out from your server via SSH:
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
# Then flush the nat and mangle tables, flush all chains (-F), and delete all non-default chains (-X):
sudo iptables -t nat -F
sudo iptables -t mangle -F
sudo iptables -F
sudo iptables -X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment