Created
February 6, 2014 17:19
-
-
Save dustywusty/8848613 to your computer and use it in GitHub Desktop.
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 | |
iptables -X | |
iptables -P INPUT DROP | |
iptables -P OUTPUT DROP | |
iptables -P FORWARD DROP | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A OUTPUT -o lo -j ACCEPT | |
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# http outbound | |
iptables -A INPUT -p tcp --source-port 80 -m state --state ESTABLISHED -j ACCEPT | |
iptables -A OUTPUT -p tcp --destination-port 80 -m state --state NEW -j ACCEPT | |
# https outbound | |
iptables -A INPUT -p tcp --destination-port 443 -m state --state ESTABLISHED -j ACCEPT | |
iptables -A OUTPUT -p tcp --source-port 443 -m state --state NEW -j ACCEPT | |
# mongodb private network | |
iptables -A INPUT -s 10.128.240.125 -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT | |
iptables -A OUTPUT -d 10.128.240.125 -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT | |
# ssh | |
iptables -A INPUT -p tcp --dport 22 -j ACCEPT | |
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT | |
# dns | |
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT | |
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT | |
# ping outbound | |
iptables -A OUTPUT -p icmp --icmp-type 8 -s $SERVER_IP -d 0/0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | |
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -d $SERVER_IP -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -A INPUT -j DROP | |
iptables -A OUTPUT -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment