title: How do I open up port 3306(MySQL) for a whitelisted IP address using Iptables?
body: <p>I have a co-worker who is a member of our company that needs to access our MySQL server, on the standard port 3306, from his home. He will be accessing it via a PHP script using a mysqli connection. Even though I have added access for him via mysql, he was unable to connect for getting the dreaded "connection refused" message. I temporarily disabled iptables and had him try and he was able to connect. But of course I had to turn iptables back on and now he once again cannot connect.</p>
  
  <p>I saved iptables rules to a file and checked and the only line in there referring to port 3306 was this:</p>
  
  <pre><code>-A OUTPUT -p tcp -m tcp --dport 3306 -j ACCEPT
  </code></pre>
  
  <p>I am not an expert at iptables but am assuming that since there is no "INPUT" rule for 3306, it means port 3306 is closed to any incoming traffic. So my question is very simple and very direct: How can I still keep that port closed to everyone EXCEPT him? In other words, how can I allow his IP address only to use INCOMING traffic on port 3306 and no others while keeping the server working for OUTPUT traffic? It is also noteworthy to mention that his IP address is dynamic and will change every so often so I would also like to know how to remove access to the IP address once its in there and replace it with a new one. Thanks.</p>