Created
October 4, 2014 10:34
-
-
Save luthfianto/d5ca66bf48db5fc6d732 to your computer and use it in GitHub Desktop.
Some simple iptables rule
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
iptables -F | |
#Prevent DDOS, kudos to Digital Ocean | |
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP | |
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP | |
iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT | |
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | |
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT | |
iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT | |
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT | |
# Allows mosh, the mobile shell | |
iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT | |
iptables -A OUTPUT -p tcp --dport 80 --sport 32786:61000 -j ACCEPT | |
iptables -A INPUT -p tcp --dport 80 --sport 32786:61000 -j ACCEPT | |
iptables -A OUTPUT -p tcp --dport 32786:61000 --sport 80 -j ACCEPT | |
iptables -A INPUT -p tcp --dport 32786:61000 --sport 80 -j ACCEPT | |
# Allows established input (ex: allows DNS resolving) | |
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# Allows all output connections (for simplicity) | |
iptables -P OUTPUT ACCEPT | |
# Blocks unspecifed input connections | |
iptables -P INPUT DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment