Skip to content

Instantly share code, notes, and snippets.

@rick4470
Created March 30, 2017 22:24
Show Gist options
  • Save rick4470/2cb06a2954991438f0f9d97ccec26408 to your computer and use it in GitHub Desktop.
Save rick4470/2cb06a2954991438f0f9d97ccec26408 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