Skip to contentSkip to conversation

How to redirect OUTPUT traffic to another port

DISCUSSION Oliver Sperke 1 participant 1 message May 3, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I googled for hours, but could not find an answer. I establish a ssh tunnel on server 1. The traffic is marked on the OUTPUT chain with the owner attribute and then redirected on ip route to server 2. Everything works so far. But how do I redirect the outgoing traffic from port 80 to port 3080r? As far as I understand I can use the the OUTPUT chain to redirect the port but then nothing works anymore. It seems like the traffic is just dropped. My idea was:

iptables -t mangle -A OUTPUT -m owner --uid-owner 2000 -j MARK --set-mark 0x1
32765: from #serverip# fwmark 0x1 lookup #gateway#

This works so far, but this not:

iptables -t nat -A OUTPUT -s #serverip# -m owner --uid-owner 2000 -p tcp --dport 80 -j REDIRECT --to-ports 3080

Can anybody help me?

Oliver