* How does iptables redirect a packet that is not addressed to its local machine
@ 2004-04-08 1:16 Grace Li
2004-04-07 22:44 ` Nicholas E. Walker
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Grace Li @ 2004-04-08 1:16 UTC (permalink / raw)
To: netfilter-devel
[-- Attachment #1: Type: text/plain, Size: 653 bytes --]
Hi,
I am just wondering if anybody could explain what happened in the following experiments:
Client (192.168.1.134) tries to connect to port 1888 of Server
(192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
The results of my experiments is that the application on Gateway who listens
to port 2000 could not get anything, while Server receives everything
expected on its port 1888. So my question is that did iptables do anything
here?
Many thanks,
Grace
[-- Attachment #2: Type: text/html, Size: 1314 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: How does iptables redirect a packet that is not addressed to its local machine
2004-04-08 1:16 How does iptables redirect a packet that is not addressed to its local machine Grace Li
@ 2004-04-07 22:44 ` Nicholas E. Walker
2004-04-07 23:06 ` Nicholas E. Walker
2004-04-07 22:48 ` Henrik Nordstrom
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Nicholas E. Walker @ 2004-04-07 22:44 UTC (permalink / raw)
To: netfilter-devel
On Wed, Apr 07, 2004 at 06:16:07PM -0700, Grace Li wrote:
> I am just wondering if anybody could explain what happened in the following experiments:
>
> Client (192.168.1.134) tries to connect to port 1888 of Server
> (192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
> has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
> nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
>
> The results of my experiments is that the application on Gateway who listens
> to port 2000 could not get anything, while Server receives everything
> expected on its port 1888. So my question is that did iptables do anything
> here?
If I understand what you are trying to do correctly, you need to use the
DNAT target instead of the REDIRECT target. The REDIRECT target is for
intercepting packets and redirecting them to ports on the gateway
machine.
Try:
iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.115 --dport 1888 \
-j DNAT --to-destination 192.168.1.115:2000
I don't believe there is a target for re-mapping destination ports
without re-mapping addresses. One cannot simply change the destination
port on the packet as it passes through, because the source port on
packets coming back from the server need to be mangled as well.
Nicholas
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: How does iptables redirect a packet that is not addressed to its local machine
2004-04-07 22:44 ` Nicholas E. Walker
@ 2004-04-07 23:06 ` Nicholas E. Walker
0 siblings, 0 replies; 7+ messages in thread
From: Nicholas E. Walker @ 2004-04-07 23:06 UTC (permalink / raw)
To: netfilter-devel
I misread. Apologies.
Nicholas
On Wed, Apr 07, 2004 at 06:44:32PM -0400, Nicholas E. Walker wrote:
> On Wed, Apr 07, 2004 at 06:16:07PM -0700, Grace Li wrote:
> > I am just wondering if anybody could explain what happened in the following experiments:
> >
> > Client (192.168.1.134) tries to connect to port 1888 of Server
> > (192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
> > has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
> > nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
> >
> > The results of my experiments is that the application on Gateway who listens
> > to port 2000 could not get anything, while Server receives everything
> > expected on its port 1888. So my question is that did iptables do anything
> > here?
>
> If I understand what you are trying to do correctly, you need to use the
> DNAT target instead of the REDIRECT target. The REDIRECT target is for
> intercepting packets and redirecting them to ports on the gateway
> machine.
>
> Try:
>
> iptables -t nat -A PREROUTING -i eth0 -d 192.168.1.115 --dport 1888 \
> -j DNAT --to-destination 192.168.1.115:2000
>
> I don't believe there is a target for re-mapping destination ports
> without re-mapping addresses. One cannot simply change the destination
> port on the packet as it passes through, because the source port on
> packets coming back from the server need to be mangled as well.
>
> Nicholas
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How does iptables redirect a packet that is not addressed to its local machine
2004-04-08 1:16 How does iptables redirect a packet that is not addressed to its local machine Grace Li
2004-04-07 22:44 ` Nicholas E. Walker
@ 2004-04-07 22:48 ` Henrik Nordstrom
2004-04-07 23:40 ` Phil Oester
2004-04-08 5:44 ` zhi wang
3 siblings, 0 replies; 7+ messages in thread
From: Henrik Nordstrom @ 2004-04-07 22:48 UTC (permalink / raw)
To: Grace Li; +Cc: netfilter-devel
On Wed, 7 Apr 2004, Grace Li wrote:
> Hi,
>
> I am just wondering if anybody could explain what happened in the following experiments:
>
> Client (192.168.1.134) tries to connect to port 1888 of Server
> (192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
> has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
> nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
Works here...
> The results of my experiments is that the application on Gateway who listens
> to port 2000 could not get anything, while Server receives everything
> expected on its port 1888. So my question is that did iptables do anything
> here?
No idea. This is a kind of thing which has always worked for me, but you
are the second person in a few days reporting this is not working..
Exacly what kernel and iptables version are you using on the gateway?
What does "iptables-save -t nat" give?
Regards
Henrik
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How does iptables redirect a packet that is not addressed to its local machine
2004-04-08 1:16 How does iptables redirect a packet that is not addressed to its local machine Grace Li
2004-04-07 22:44 ` Nicholas E. Walker
2004-04-07 22:48 ` Henrik Nordstrom
@ 2004-04-07 23:40 ` Phil Oester
2004-04-08 5:44 ` zhi wang
3 siblings, 0 replies; 7+ messages in thread
From: Phil Oester @ 2004-04-07 23:40 UTC (permalink / raw)
To: Grace Li; +Cc: netfilter-devel
Perhaps you haven't added a corresponding rule to the INPUT table
to actually allow port 2000 to the gateway?
Phil
On Wed, Apr 07, 2004 at 06:16:07PM -0700, Grace Li wrote:
> Hi,
>
> I am just wondering if anybody could explain what happened in the following experiments:
>
> Client (192.168.1.134) tries to connect to port 1888 of Server
> (192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
> has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
> nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
>
> The results of my experiments is that the application on Gateway who listens
> to port 2000 could not get anything, while Server receives everything
> expected on its port 1888. So my question is that did iptables do anything
> here?
>
> Many thanks,
>
> Grace
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How does iptables redirect a packet that is not addressed to its local machine
2004-04-08 1:16 How does iptables redirect a packet that is not addressed to its local machine Grace Li
` (2 preceding siblings ...)
2004-04-07 23:40 ` Phil Oester
@ 2004-04-08 5:44 ` zhi wang
3 siblings, 0 replies; 7+ messages in thread
From: zhi wang @ 2004-04-08 5:44 UTC (permalink / raw)
To: Grace Li; +Cc: Netfilter Develop
> Client (192.168.1.134) tries to connect to port 1888 of Server
> (192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the iptables
> has been instructed to redirect traffic on port 1888 to 2000 (iptables -t
> nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 ).
At the client execute:
traceroute -n 192.168.1.115
to make sure that the client DID send the packet to the gateway
__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway
http://promotions.yahoo.com/design_giveaway/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How does iptables redirect a packet that is not addressed to its local machine
@ 2004-04-08 1:47 wanghtb
0 siblings, 0 replies; 7+ messages in thread
From: wanghtb @ 2004-04-08 1:47 UTC (permalink / raw)
To: netfilter-devel; +Cc: zheyinli
Hi, I wonder if the Client and the Server are in the same network,
under which the Gateway will send a ICMP Redirect message to
make the Client access Server directly.
Please check netmask of the Machines and use tcpdump packet in the
Gateway to see what happens:-)
>Hi,
>
>I am just wondering if anybody could explain what happened in the =
>following experiments:
>Client (192.168.1.134) tries to connect to port 1888 of Server
>(192.168.1.115) through Gateway (192.168.1.1). In the Gateway, the =
>iptables
>has been instructed to redirect traffic on port 1888 to 2000 (iptables =
>-t
>nat -A PREROUTING -i eth0 -p tcp --dport 1888 -j REDIRECT -to-port 2000 =
>).
>
>The results of my experiments is that the application on Gateway who =
>listens
>to port 2000 could not get anything, while Server receives everything
>expected on its port 1888. So my question is that did iptables do =
>anything
>here?
>
>Many thanks,
>
>Grace
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-04-08 5:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-08 1:16 How does iptables redirect a packet that is not addressed to its local machine Grace Li
2004-04-07 22:44 ` Nicholas E. Walker
2004-04-07 23:06 ` Nicholas E. Walker
2004-04-07 22:48 ` Henrik Nordstrom
2004-04-07 23:40 ` Phil Oester
2004-04-08 5:44 ` zhi wang
-- strict thread matches above, loose matches on Subject: below --
2004-04-08 1:47 wanghtb
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.