S
S
sleepnow2015-12-31 19:24:09
iptables
sleepnow, 2015-12-31 19:24:09

Forwarding iptables traffic to a port and back?

Good afternoon friends!
There is an Openvz container. It has a couple of external IPs.
Let's say it's xxxx
He is in the Russian Federation.
There is a server with port 8900 which sits on ip yyyy and it is located on the territory of Ukraine.
It just so happened that knocking on Yyyy from the home Internet - packets are lost, and if xxxx knocks on yyyy - everything is fine
.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-12-31
@rostel

iptables -t nat -A PREROUTING -d x.x.x.x -p tcp -m tcp --dport 8900 -j DNAT --to-destination y.y.y.y:8900
iptables -t nat -A POSTROUTING  -d y.y.y.y -j SNAT --to-source x.x.x.x
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp -m tcp -d y.y.y.y --dport 8900 -j ACCEPT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question