From: Philip Craig <philipc@snapgear.com>
To: Timothy Meader <Timothy.Meader@gsfc.nasa.gov>
Cc: netfilter@vger.kernel.org
Subject: Re: Setting Source IP for outgoing traffic?
Date: Tue, 30 Oct 2007 17:53:41 +1000 [thread overview]
Message-ID: <4726E305.3050008@snapgear.com> (raw)
In-Reply-To: <6.2.5.6.2.20071024220938.034412a8@gsfc.nasa.gov>
Timothy Meader wrote:
> Basically, I need the responses to any traffic coming in on UDP port
> 1514 (or, alternatively, to the destination IP x.29) to go back out
> with a src address of x.29 instead of x.17 or x.18. Is there a method
> using iptables that can handle this problem? Or barring that, can
> anyone think of any other means to accomplish this task if iptables
> can't handle this on its own? Below, I've included the current
> iptables data rules that the two cluster nodes are presently sharing.
You could try a source NAT rule, eg
iptables -t nat -A POSTROUTING -p udp --sport 1514 -j SNAT --to-source xxx.xxx.xxx.29
but I'm not sure that this will work, since the tuple will clash with
the connection that was created for the incoming packet.
You can't use iptables to do policy routing based on port, since that
happens after address selection.
The proper fix is to change OSSEC to use the correct source address
for its replies. I can think of two ways for this.
First, OSSEC could bind() to a specific address instead of INADDR_ANY.
I don't know if it already has a config option to do this.
Second, OSSEC could use the IP_PKTINFO socket option to determine the
address it received a packet on, and send its reply using this as the
source address. For an example of an application that does this, see
openswan (the code is in lib/libopenswan/udpfromto.c).
prev parent reply other threads:[~2007-10-30 7:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-25 2:47 Setting Source IP for outgoing traffic? Timothy Meader
2007-10-30 7:53 ` Philip Craig [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4726E305.3050008@snapgear.com \
--to=philipc@snapgear.com \
--cc=Timothy.Meader@gsfc.nasa.gov \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox