From: Andrew Beverley <andy@andybev.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter@vger.kernel.org, Pandu Poluan <pandu@poluan.info>
Subject: Re: Routing locally generated traffic on fwmark
Date: Thu, 29 Sep 2011 18:28:38 +0100 [thread overview]
Message-ID: <1317317318.26402.271.camel@andybev-desktop> (raw)
In-Reply-To: <alpine.LNX.2.01.1109291224580.18982@frira.zrqbmnf.qr>
On Thu, 2011-09-29 at 12:28 +0200, Jan Engelhardt wrote:
> On Thursday 2011-09-29 08:51, Andrew Beverley wrote:
> >> iptables -A OUTPUT -t mangle -d 89.16.176.81 -j MARK --set-mark 0x800
> >> ip rule add fwmark 0x800/0xffff table T2
> >> ip route add table T2 default dev ppp1 via 94.30.127.76
> >
> >I've also added the following, which makes no difference:
> >
> >iptables -t nat -A POSTROUTING -o ppp1 \
> > -j SNAT --to-source 109.224.134.110
>
> Of course it makes no difference, because SNAT is applied after routing.
> ("POST" "ROUTING", see?)
Yes, but in my case the SNAT still needed applying. The problem was that
although the packets were being routed via the second interface, they
were still being sent from the original IP address of the first
interface. Therefore, packets were being returned to the first
interface, making it look as if the second interface wasn't being used.
>
> >So, I assume the problem is that the packet is marked too late to affect
> >the routing.
> >Looking at the packet flow diagram[1] though, there should
> >be a re-route check after the mangle table, which should re-route if a
> >packet's mark has changed. Does this feature need enabling?
>
> mangle is the right place; in its code you will find
>
> ret = ipt_do_table(skb, NF_INET_LOCAL_OUT, NULL, out,
> dev_net(out)->ipv4.iptable_mangle);
> /* Reroute for ANY change. */
> if (ret != NF_DROP && ret != NF_STOLEN) {
> iph = ip_hdr(skb);
> if (iph->saddr != saddr ||
> iph->daddr != daddr ||
> skb->mark != mark ||
> iph->tos != tos)
> if (ip_route_me_harder(skb, RTN_UNSPEC))
> ret = NF_DROP;
Thanks, that helps. Useful to know exactly what is going on.
Thanks for all the help.
Andy
next prev parent reply other threads:[~2011-09-29 17:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 22:20 Routing locally generated traffic on fwmark Andrew Beverley
2011-09-29 6:51 ` Andrew Beverley
2011-09-29 7:32 ` Pandu Poluan
2011-09-29 7:53 ` [SOLVED] " Andrew Beverley
2011-09-29 8:29 ` Pandu Poluan
2011-10-02 13:11 ` Ed W
2011-09-29 10:28 ` Jan Engelhardt
2011-09-29 17:28 ` Andrew Beverley [this message]
2011-09-29 17:35 ` Jan Engelhardt
2011-09-29 17:46 ` Andrew Beverley
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=1317317318.26402.271.camel@andybev-desktop \
--to=andy@andybev.com \
--cc=jengelh@medozas.de \
--cc=netfilter@vger.kernel.org \
--cc=pandu@poluan.info \
/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