Categories
Development

Allow connections to mysql through firewall (IPTABLES) from your network.

*Not in production*

List the content of your iptables and display your numbers.
sudo iptables -n -L --line-numbers

In my case, at the 7th line was the drop all line so it’s the place where I want to insert.
eth1 is the network interface on my computer that I wanted to allow access on. Run ifconfig to know which one you want to apply it on.
To give access to my network, I used a netmask 192.168.56.0/24
3306 is the default mysql port.

sudo iptables -I INPUT 7 -i eth1 -p tcp --dport 3306 -s 192.168.56.0/24 -j ACCEPT -m comment --comment "MySQL"

Do not forget to save !
sudo /etc/init.d/iptables-persistent save
sudo /etc/init.d/iptables-persistent reload

Reference:
snipt johan_adriaans
CentOS HowTos Network IPTables
AskUbuntu (Answer from user213088)