I have: Workstation with OpenSuse 11.4 x64, single NetworkCard.
Task. Redirects all local outgoing connection to ip x.x.x.x:80 to localhost:5222.
Tried this command:
iptables -t nat -A OUTPUT -p tcp -d x.x.x.x --dport 80 -j REDIRECT --to-ports 5222
After adding this rule I can’t connect x.x.x.x:80 anymore, connection hangs.
There are no more rules in a ‘nat’ table.
Also, I’ve tried to use DNAT command. Effect was the same.
Having a LAN trace or /var/log/firewall output may help but where in your
rule did you specify the destination host? I see the port, but will that
just send to 5222 on the x.x.x.x machine rather than localhost?
Good luck.
On 04/05/2011 12:36 AM, a kireev wrote:
>
> I have: Workstation with OpenSuse 11.4 x64, single NetworkCard.
> Task. Redirects all local outgoing connection to ip x.x.x.x:80 to
> localhost:5222.
>
> Tried this command:
> iptables -t nat -A OUTPUT -p tcp -d x.x.x.x --dport 80 -j REDIRECT
> --to-ports 5222
> After adding this rule I can’t connect x.x.x.x:80 anymore, connection
> hangs.
> There are no more rules in a ‘nat’ table.
>
> Also, I’ve tried to use DNAT command. Effect was the same.
>
> How to make it works?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
Your situation is similar to the rules that are used when all outgoing HTTP connections must be transparently directed to a web proxy, except that in your case you only want to enforce it for a single destination. You need a pair of rules, one to do the DNAT and the other to do the REDIRECT. See this HOWTO for squid and modify the two iptables rules there to limit the effect to one destination IP.