Created
March 30, 2017 22:24
-
-
Save rick4470/2cb06a2954991438f0f9d97ccec26408 to your computer and use it in GitHub Desktop.
Block all traffic to 27017
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
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