Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucydjo/b0566d4c6de53d5d2785a2a8f5275e6a to your computer and use it in GitHub Desktop.
Save lucydjo/b0566d4c6de53d5d2785a2a8f5275e6a to your computer and use it in GitHub Desktop.
Block all traffic to 27017
iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 27017 -j DROP
iptables -I INPUT -p tcp -s 127.0.0.1 --dport 27017 -j ACCEPT
iptables -I INPUT -p tcp -s <IP GOES HERE> --dport 27017 -j ACCEPT
iptables-save > /etc/iptables.conf # Save this changes to file
touch /etc/network/if-up.d/iptables # Create file to call conf from
echo "iptables-restore < /etc/iptables.conf" >> /etc/network/if-up.d/iptables # Add this line to this file
chmod +x /etc/network/if-up.d/iptables # Make the script executable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment