Skip to contentSkip to conversation

How does iptables redirect a packet that is not addressed to its local machi

DISCUSSION Grace Li 3 participants 3 messages Apr 8, 2004 netfilter

lore
Share & tools
lore

Grace Li

author
#0 lore raw

Yes, Client and Server are in the same network!

I used the Ethereal tool, which is similiar to but better than tcpdump. On Client, Server and Gateway, I could all always see that packets are sending back and forth from Server and Client. There is no sign that Gateway receives packets on port 1888 or 2000.

Thanks,

Grace

Quoted 6 lines

From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: How does iptables redirect a packet that is not addressed to its local machine
Date: Thu, 8 Apr 2004 09:47:15 +0800

Quoted 31 lines

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. version is iptables

Please check netmask of the Machines and use tcpdump packet in the Gateway to see what happens:-)

Quoted 23 lines

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

_________________________________________________________________
STOP MORE SPAM with the MSN Premium and get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines

#1 lore raw

Hi Grace,

Quoted 6 lines

Yes, Client and Server are in the same network!

I used the Ethereal tool, which is similiar to but better than tcpdump. On Client, Server and Gateway, I could all always see that packets are sending back and forth from Server and Client. There is no sign that Gateway receives packets on port 1888 or 2000.

If you ping the Server from the Client, does it go through the Gateway? Probably not, because Client and Server are in the same subnet and on the same physical LAN. In this case, the packets never arrive at Gateway, so iptables on Gateway can't do anything to intercept or modify them.

You could try setting a route on the Client which points to the Server, but using Gateway as the gateway of the route.

Cheers, Chris.

Signature · 4 lines
_  __ __     _
 / __/ / ,__(_)_  | Chris Wilson -- UNIX Firewall Lead Developer |
/ (_  ,\/ _/ /_ \ | NetServers.co.uk http://www.netservers.co.uk |
\__/_/_/_//_/___/ | 21 Signet Court, Cambridge, UK. 01223 576516 |
#2 lore raw
In reply to Grace Li
Quoted 1 line · Grace Li

Yes, Client and Server are in the same network!

For IPTABLES to work on the gateway both the client and server MUST send the traffic via the gateway. You can not have iptables on the gateway magically work on traffic which goes directly between the client<->server not involving the gateway..

Regards
Henrik