E
E
Evgeny Petryaev2019-07-23 15:40:03
MySQL
Evgeny Petryaev, 2019-07-23 15:40:03

Forward mysql port to different subnet?

The Internet goes to 192.168.1.1 there is such a rule
5d36ffba45279355600123.jpeg
i.e. when a request comes from an external address to the mysql port, it redirects to 192.168.1.2 now it needs to be redirected to 192.168.0.3 and the diagram is attached5d370019e2fa3676529789.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petryaev, 2019-07-23
@Gremlin92

sudo iptables -A FORWARD -i enp3s1 -o enp3s0 -p tcp --syn --dport 3306 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -i enp3s1 -o enp3s0 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -i enp3s0 -o enp3s1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A PREROUTING -i enp3s1 -p tcp --dport 3306 -j DNAT --to-destination 192.168.0.3
sudo iptables -t nat -A POSTROUTING -o enp3s0 -p tcp --dport 3306 -d 192.168.0.3 -j SNAT --to-source 192.168.1.2

In principle, it works well

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question