title: Restricting MySQL 3306 port to localhost with IPTABLES
body: <p>I am trying to restrict MySQL 3306 port on a linux machine from making any connections to anything other than localhost to prevent outside attacks. i have the following code, i am not sure if it's correct:</p>
  
  <blockquote>
  <pre><code>iptables -A INPUT -p tcp -s localhost --dport 3306 -j ACCEPT
  
  iptables -A OUTPUT -p tcp -s localhost --dport 3306 -j ACCEPT
  
  iptables -A INPUT -p tcp --dport 3306 -j DROP
  
  iptables -A OUTPUT -p tcp --dport 3306 -j DROP
  </code></pre>
  </blockquote>
  
  <p>my other question is - is it correct to only give localhost access? this is a standard dedicated centos webserver with more than 30 domains on it.</p>