P
P
paralolik2020-11-24 16:31:17
iptables
paralolik, 2020-11-24 16:31:17

How to FORWARD from one ip to another via iptables?

I'm trying to study this topic, but for me, a beginner, NAT is still something far away.

I have two servers at home connected to the same router, the router sends all traffic via an external IP to the first server via DMZ Host, I had to redirect this traffic from the first (.23) to the second server (.30) when connecting via port 2332

I found a working option for me that redirects traffic if you connect via the public IP of the router

iptables -t nat -A PREROUTING -i enp3s0 -p tcp --dport 2332 -s 192.168.0.23 -j DNAT --to 192.168.0.30:2332
iptables -t nat -A POSTROUTING -j MASQUERADE

but if you connect from the internal 192.168.0.0 network, then it does not redirect, as well as if you connect from the gateway itself. How to make it redirect traffic within the network?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2020-11-26
@paralolik

Confusing wording of the question. Either the above rules are on your router, or these rules are on the first server ...
But in a nutshell - google according to the words "hairpin NAT".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question