Skip to content

Instantly share code, notes, and snippets.

@joebarbere
Created July 26, 2012 01:15
Show Gist options
  • Save joebarbere/3179707 to your computer and use it in GitHub Desktop.
Save joebarbere/3179707 to your computer and use it in GitHub Desktop.
mongodb iptables
#!/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