port redirection *without* nat
I'm trying to figure out how (if possible) to do port redirection with iptables on my linux router. This router is is not doing NAT, all connected networks have real, public IP addresses. There is tons of information out there about doing port redirection with NAT, but I can't find anything for without NAT. I just want to make the router take traffic destined for address A port x and change the destination address to send it off to address B port x instead. A and B are on the same (directly attached ethernet) network. I looked into the DNAT and REDIRECT targets, but those only seem to work in the nat table.
Thanks
Quoted 9 lines · On Mon, Jan 06, 2003 at 02:17:53PM -0500, [email protected] wrote:
I'm trying to figure out how (if possible) to do port redirection with iptables on my linux router. This router is is not doing NAT, all connected networks have real, public IP addresses. There is tons of information out there about doing port redirection with NAT, but I can't find anything for without NAT. I just want to make the router take traffic destined for address A port x and change the destination address to send it off to address B port x instead. A and B are on the same (directly attached ethernet) network. I looked into the DNAT and REDIRECT targets, but those only seem to work in the nat table.
Um, think about it. You DO want 'NAT' of some sort for this.
Connection comes in from 1.2.3.4:1234 destined to A:x. You want this to be handled by B:x. So you use a DNAT or REDIRECT to re-write the destination, good, now have the connection ultimately ending up at B:x. But as far as 1.2.3.4:1234 is concerned it IS talking to A:x, so the return packets MUST be rewritten to come back from A:x, which is what DNAT will do.
If you want B:x to completely handle the connection then you need the
clients to be just connecting to it directly in the first place, with requisite INPUT/FORWARD rules setup to allow this.
-Ath
Signature · 4 lines
- Athanasius = Athanasius(at)miggy.org / http://www.miggy.org/
Finger athan(at)fysh.org for PGP key
"And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - MEQuoted 9 lines · On Monday 06 January 2003 02:17 pm, [email protected] wrote:
I'm trying to figure out how (if possible) to do port redirection with iptables on my linux router. This router is is not doing NAT, all connected networks have real, public IP addresses. There is tons of information out there about doing port redirection with NAT, but I can't find anything for without NAT. I just want to make the router take traffic destined for address A port x and change the destination address to send it off to address B port x instead. A and B are on the same (directly attached ethernet) network. I looked into the DNAT and REDIRECT targets, but those only seem to work in the nat table.
What you say you are trying to do IS DNAT. A packet reaches the machine addressed to one destination, but you want to send it to another address instead, changing the Destination IP. Destination NAT. And yes, such targets only work in the nat table's chains, and for DNAT you want to use the PREROUTING chain. The REDIRECT target is for picking traffic out of the stream that would normally be forwarded and DNATting it to readdress it to the local box as INPUT instead.
The most frequently mentioned use of DNAT is for packets addressed to an IP of the box itself, but this isn't necessary. DNAT is simply changing the destination IP, regardless of what it originally was.
j