Created
June 6, 2014 14:34
-
-
Save Rembane/2854df9be4384e2972af to your computer and use it in GitHub Desktop.
This is my firewall restoration script.
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
#!/bin/bash | |
iptables -F # Flush all! | |
iptables -X # Delete all custom chains! | |
iptables -t nat -F | |
iptables -t nat -X | |
iptables -t mangle -F | |
iptables -t mangle -X | |
iptables -P INPUT ACCEPT | |
iptables -P FORWARD ACCEPT | |
iptables -P OUTPUT ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT # Accept all from the loopback interface | |
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT # Accept established connections | |
# SSH and HTTP | |
iptables -A INPUT -p tcp --dport ssh -j ACCEPT | |
iptables -A INPUT -p tcp --dport 80 -j ACCEPT | |
#iptables -A INPUT -p tcp --dport 8080 -j ACCEPT | |
# Ping | |
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT | |
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT | |
# Drop everything else | |
iptables -A INPUT -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment