Created
November 15, 2015 09:31
-
-
Save shlomi-noach/a2a2a65872529c1f34d2 to your computer and use it in GitHub Desktop.
Block/unblock MySQL 3306 access via 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 | |
# | |
# Usage: block_mysql_access.bash [true|false] | |
# "true" or empty input blocks 3306 access, via iptables | |
# "false" re-enables access to 3306 | |
# | |
if [ $# -eq 0 ] || [ "$1" == "true" ]; then | |
sudo -i /sbin/iptables -I INPUT -p tcp --destination-port 3306 -j REJECT | |
elif [ "$1" == "false" ]; then | |
sudo -i /sbin/iptables -D INPUT -p tcp --destination-port 3306 -j REJECT | |
else | |
echo "Bad input" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment