I did port forwarding following this tutorial: http://www.debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/
iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 2.2.2.2:1111
iptables -t nat -A POSTROUTING -j MASQUERADE
But i want to MASQUERADE just the ports with the forwardings, because in the same server i have a webserver and if i MASQUERADE all the traffic the web server stops working.
Any idea?
SOLUTION:
iptables -t nat -A POSTROUTING -d 2.2.2.2 -p tcp --dport 1111 -j SNAT --to-source 2.2.2.1
iptables -t nat -A POSTROUTING -p tcp --sport 1111 -j MASQUERADE
(a space between - p) This was not the error, because i set up like this2 MASQUERADE tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:40002
and it doesn't work, any idea?? Thanks