LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-08-2004, 11:46 AM   #1
bentz
Member
 
Registered: Mar 2003
Distribution: Fedora, Mac OSX
Posts: 362

Rep: Reputation: 30
iptables POSTROUTING doesn't match local-process replies.


Hello,
I need to change the source address of a reply packet leaving a machine running iptables. I am tring to accomplish this using POSTROUTING -j SNAT.

When a request comes into a server and is destined for a local process (i.e. apache, sshd, etc.) it's reply leaves the machine without ever touching the POSTROUTING chain-- the 'hit' counters (iptables -t nat -L POSTROUTING -n -v) never increment as a packet passes through, and my POSTROUTING -j SNAT rule never gets to mangle the packet's source address. POSTROUTING works file if the connection is being routed through a machine, and does not involve a local process.

I need to get this working to support a firmware-based load balancing device. In order to avoid out-of-state connections, I need to have the web server replies come from the same source address as the load balacing device's destination address, and therefore I need to translate the packets leaving the webserver.

Can any one explain to me how to get POSTROUTING to process packets leaving a local-process on a machine?

Thanks in advance.
 
Old 03-09-2004, 02:59 AM   #2
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
The packets do traverse the POSTROUTING chain...
However, the NAT is effective from the first handshake and once the stream is considered ESTABLISHED, no further packets pass to the chain.

Also you may need to be more specific in the rule to define which source is going to be SNATted.
The rules work best with interface definitions...
 
Old 03-09-2004, 12:02 PM   #3
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Check out this site which give a very nice overview of the traversal of tables and chains.
http://iptables-tutorial.frozentux.net/
 
Old 03-10-2004, 06:34 PM   #4
bentz
Member
 
Registered: Mar 2003
Distribution: Fedora, Mac OSX
Posts: 362

Original Poster
Rep: Reputation: 30
So, basically you're saying that if a packet already has an ESTABLISHED state, that it will then not traverse the POSTROUTING chain? This would seem to be consistent with the tests I've performed, where replies from the webserver (which, therefore are ESTABLISHED) don't seem to get modified.

Any way around this behaviour?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables: No chain/target/match by that name qanopus Linux - Networking 6 01-04-2009 09:10 PM
Iptables postrouting question phatboyz Linux - Networking 8 01-31-2005 01:58 PM
Iptables mac-match VS. transparent proxy mchanea Linux - Security 4 12-22-2004 06:42 AM
"iptables: No chain/target/match by that name" error PennyroyalFrog Linux - Security 2 11-28-2004 01:57 PM
iptables string match kahpeetan Linux - Security 3 11-09-2003 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration