# ipfw and mysql setup



## svan (Dec 18, 2012)

Hello, I have a server which always getting attacks on my mysql server, how can I setup some rules to allow local machine to mysql and allow on of my remote host ips to connect only?

me I did this:

```
ipfw add deny ip from any to me dst-port 3306
ipfw add allow ip from 127.0.0.0/8 to any dst-port 3306
ipfw add allow ip from REMOTE HOST IP to me dst-port 3306
```
but I can still connect from any ip to port 3306, is there any option that I can allow port 3306 open to a specific ip only?

thanks.


----------



## svan (Dec 18, 2012)

hi there
So I manage to figure it out and make how I wanted 

I added into my firewall rules this 2 rules:

```
$IPF 120 allow tcp from REMOTE HOST to LOCAL HOST 3306
$IPF 200 deny tcp from any to any 3306
```
and is worry perfect  no one can acces mysql now, only the REMOTE HOST can do it.


----------

