I\'m trying to connect to MySQL (Port 3306) from a network which blocks this port. But there is another port 110 open which I can use for this case. I\'m using MySQL for other a
When forwarding ports on ubuntu using iptables, you must:
sudo iptables-save > iptables.backup
sudo ufw allow 110/tcp
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 110 -j REDIRECT --to-port 3306
Notice the use of -i eth0
. This routes port 110 to 3306 on network eth0. To check all connection of your machine, use ifconfig
.
If your machine is connected to multiple networks, you must use -i <network>
or it will not work!
sudo iptables -F -t nat
or restore iptables
sudo iptables-restore < iptables.backup
This might work, haven't tested it.
iptables -t nat -A PREROUTING -p tcp --dport 110 -j REDIRECT --to-port 3306