Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@vger.kernel.org
Subject: Re: How to route per process?
Date: Tue, 23 Jun 2009 11:12:22 +0200	[thread overview]
Message-ID: <4A409C76.103@plouf.fr.eu.org> (raw)
In-Reply-To: <3cda010470e818a0d5c1c025716ded6e.squirrel@webmail.sonic.net>

Hello,

ulmo@sonic.net a écrit :
> 
> The software in question has the capability to bind to specified
> addresses, but not to send packets out over specified interfaces, which is
> necessary.

It is easy to do source address-based routing.
ip rule from <address> lookup <table>

> iptables -t mangle -A OUTPUT -m owner --uid-owner asterisk -j MARK
> --set-mark 42 &&
> iptables -t nat -A POSTROUTING -o $dev -m mark --mark 42 -j SNAT
> --to-source $ifaceaddr &&
> ip rule add fwmark 42 table 42 &&
> ip route add default via $gw dev $dev table 42
> 
> To wit, all the above works, except that when the packets come back, the
> process in question doesn't receive them.  tcpdump shows everything
> working as desired up to that point:  the packets go out, they get
> responses which come back.  The disconnect is somewhere between the return
> packets coming back and them being put into the process's connection as
> desired inside the OS, I'm pretty sure.

Check your iptables filtering rules, and that source validation by 
reverse path filtering is disabled on the alternate interface 
(/proc/sys/net/ipv4/conf/<interface>/rp_filter=0). It is disabled by 
default in the kernel, but startup scripts in some distributions enable it.

      parent reply	other threads:[~2009-06-23  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-21  2:10 How to route per process? ulmo
2009-06-21 18:37 ` ulmo
2009-06-23  9:12 ` Pascal Hambourg [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=4A409C76.103@plouf.fr.eu.org \
    --to=pascal.mail@plouf.fr.eu.org \
    --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