Created
July 26, 2012 01:15
-
-
Save joebarbere/3179707 to your computer and use it in GitHub Desktop.
mongodb iptables
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 | |
| # Flush all current rules from iptables | |
| iptables -F | |
| # Allow established connections | |
| iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
| # Allow MongoDB | |
| iptables -A INPUT -s 10.182.226.217 -p tcp --dport 27017 -j ACCEPT | |
| # Allow SSL on non standard port | |
| iptables -A INPUT -p tcp --dport 33333 -j ACCEPT | |
| # Allow local ICMP ping | |
| iptables -A INPUT -s 10.182.226.217 -p icmp --icmp-type echo-request -j ACCEPT | |
| # Drop everything else | |
| iptables -A INPUT -j DROP | |
| # Allow loopback traffic | |
| iptables -I INPUT 1 -i lo -j ACCEPT | |
| # SAVE CHANGES | |
| iptables-save > /etc/iptables.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment