DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

White List Of IP Addresses Those Are Allowed To Access MySQL On Port 3306 This Script Can Be Run On A Dedicated Box If You Do Not Want To Create MySQL Users.

10.22.2011
| 4085 views |
  • submit to reddit
        // White list of IP addresses those are allowed to access MySQL on port 3306
// This script can be run on a dedicated box if you do not want to create MySQL users.

#!/bin/sh 
# white list of IP addresses those are allowed to access MySQL on port 3306

`iptables -F INPUT`

while read server; do
`iptables -A INPUT -p tcp --dport 3306 -s $server -j ACCEPT`
done <<HERE
192.129.10.217
192.129.10.227
HERE

`iptables -A INPUT -p tcp --dport 3306 -j REJECT`
`service iptables save`

exit 0;