Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question