Created
December 24, 2015 19:26
-
-
Save ryanthegiantlion/4601bd52d7e9b4604f49 to your computer and use it in GitHub Desktop.
Firewall rules I would use temporarily on elasticsearch host, temporarily allowing all outgoing traffic originating from the host
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
# flush existing rules | |
iptables -F | |
ip6tables -F | |
# ssh rule. always add this first ! | |
# TODO: Consider rate limiting? (e.g http://www.digitalsanctuary.com/tech-blog/debian/using-iptables-to-prevent-ssh-brute-force-attacks.html) | |
# Still need to read up on implications... | |
iptables -A INPUT -p tcp --dport ssh -j ACCEPT | |
iptables -A OUTPUT -p tcp --sport ssh -j ACCEPT | |
# allow elasticsearch traffic from these hosts | |
iptables -A INPUT -s 10.x.x.x -p tcp --dport 9200:9300 -j ACCEPT | |
iptables -A INPUT -s 10.x.x.x -p tcp --dport 9200:9300 -j ACCEPT | |
iptables -A INPUT -s 10.x.x.x -p tcp --dport 9200:9300 -j ACCEPT | |
iptables -A OUTPUT -d 10.x.x.x -p tcp --sport 9200:9300 -j ACCEPT | |
iptables -A OUTPUT -d 10.x.x.x -p tcp --sport 9200:9300 -j ACCEPT | |
iptables -A OUTPUT -d 10.x.x.x -p tcp --sport 9200:9300 -j ACCEPT | |
# allow all on localhost | |
iptables -A INPUT -i lo -j ACCEPT | |
iptables -A OUTPUT -o lo -j ACCEPT | |
# allow host to be pinged | |
iptables -A INPUT -p icmp --icmp-type 8 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | |
iptables -A OUTPUT -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT | |
# allow all traffic initiated by this host | |
iptables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT | |
iptables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT | |
iptables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT | |
iptables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT | |
ip6tables -A OUTPUT -p udp -m state --state NEW,ESTABLISHED -j ACCEPT | |
ip6tables -A OUTPUT -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT | |
ip6tables -A INPUT -p udp -m state --state ESTABLISHED -j ACCEPT | |
ip6tables -A INPUT -p tcp -m state --state ESTABLISHED -j ACCEPT | |
# drop all other packets | |
iptables -A INPUT -j DROP | |
iptables -A OUTPUT -j DROP | |
iptables -A FORWARD -j DROP | |
ip6tables -A INPUT -j DROP | |
ip6tables -A OUTPUT -j DROP | |
ip6tables -A FORWARD -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment