Forwarding MySQL connection with iptables and differents network interfaces
- by Emilio Nicolás
I have a PC with Ubuntu as a router. It has a 3G connection with a public IP to the Internet, and there is a private wireless subnet. So it has two active interfaces:
ppp0: public IP (WAN)
wlan0: private IP (LAN)
With iptables I wannt to forward every MySQL connection (port 3306) to a local machine (10.42.43.10) of the subnet.
I type these iptables commands:
iptables -A PREROUTING -t nat -i ppp0 -p tcp --dport 3306 -j DNAT --to 10.42.43.10:3306
iptables -A FORWARD -p tcp -i ppp0 -o wlan0 -d 10.42.43.10 --dport 3306 -j ACCEPT
But it doesn't work. telnet publicip 3306 fails :-(
Any help will be appreciated. Thanks!