I got the following 2 commands from mysql website. I tried to change the default mysql port from 3306 to 4040 and back. But it did not work as expected.
Redirect to Proxy:
iptables -t nat -I PREROUTING -s ! 127.0.0.1 -p tcp --dport 3306 -j REDIRECT --to-ports 4040
Back to default:
iptables -t nat -D PREROUTING -s ! 127.0.0.1 -p tcp --dport 3306 -j REDIRECT --to-ports 4040
What am I missing here?
Update:
The change is being shown up in the status as follows:
# /etc/init.d/iptables status
Table: nat
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 REDIRECT tcp -- !127.0.0.1 0.0.0.0/0 tcp dpt:3306 redir ports 4040
2 REDIRECT tcp -- !127.0.0.1 0.0.0.0/0 tcp dpt:3306 redir ports 4040
Chain POSTROUTING (policy ACCEPT)
num target prot opt source destination