From: Mart Frauenlob <mart.frauenlob@chello.at>
To: netfilter@vger.kernel.org
Subject: Re: iptables MARK + ip rule fwmark on locally generated packets
Date: Fri, 22 Jan 2010 13:31:14 +0100 [thread overview]
Message-ID: <4B599A92.1030900@chello.at> (raw)
In-Reply-To: <4B5983B9.2010106@trash.net>
On 22.01.2010 11:53, netfilter-owner@vger.kernel.org wrote:
> Fredrik Ax wrote:
>> On Fri, Jan 22, 2010 at 11:09:43AM +0100, Patrick McHardy wrote:
>>
>>> Fredrik Ax wrote:
>>>> Hi guys,
>>>>
>>>> I'm a pretty experienced Linux / network developer and administrator,
>>>> but I can't get my head around this one.
>>>>
>>>> The long story is that I have a box used as router/fw/proxy running
>>>> Debian Squeeze with a customized 2.6.32 x86_64 kernel having three
>>>> interfaces (eth2,eth3,eth4) on the same external subnet. One of the
>>>> interfaces is used for doing masquerading of other
>>>> subnets. Masquerading (not snat) is chosen because the interfaces are
>>>> on dhcp, and I don't want to have to rewrite the fw rules each time I
>>>> get a new addr ... already have enough with dhclient-hooks for fixing
>>>> the routing tables dns-updates, etc ;-) What I basically want to do is
>>>> make the proxy's request to go out the same ifc as the masqueraded
>>>> packets getting a src addr of s41.s42.s43.s44. Other locally generated
>>>> packets should get a src addr s21.s22.s23.s24.
>>>>
>>>> To accomplish this I'm using iptables to mark all, to port 80, locally
>>>> generated tcp packets:
>>>>
>>>> % iptables -t mangle -vnL OUTPUT
>>>> Chain OUTPUT (policy ACCEPT 3234 packets, 2254K bytes)
>>>> pkts bytes target prot opt in out source destination
>>>> 1114 181K MARK tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 MARK set 0x4
>>>>
>>>> I have verified that the iptables rule marks them fine enough.
>>>>
>>>> Then the ip rule with prio 99 below should then catch them and route
>>>> according to table eth4 below. That rule however does, for some reason
>>>> not match those packets, instead they are routed according to table
>>>> eth2 below (prio 200 rule), getting src addr s21.s22.s23.s24. If I
>>>> disable that rule they are routed according the the prio 300 rule
>>>> (getting src addr s31.s32.s33.s34).
>>>>
>>>> ...
>>>>
>>>>
>>>> What am I doing wrong here?
>>> Source address selection happens before the packet is even generated,
>>> so iptables marking in OUTPUT can't affect it.
>>
>> So, to accomplish this I would have to oute it through a dummy
>> interface to make iptables able to mark it before it goes out?
>
> You need some criteria for your routing rules that is available
> when the socket is routed. That's everything but the packet mark.
> Using a seperate device will work.
>
> For ethernet, the macvlan device might be a good choice if you
> don't mind using different MAC addresses for each IP.
sorry to jump in, but when i look at the nf packet flow picture from here:
http://jengelh.medozas.de/images/nf-packet-flow.png
it says in 'output path':
mangle OUTPUT --> reroute check --> nat OUTPUT
what does the 'reroute check' mean, if not consulting the ip rules ->
read the fwmark -> use the according routing table?
what am i missing?
thanks for help
best regards
Mart
next prev parent reply other threads:[~2010-01-22 12:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 10:07 iptables MARK + ip rule fwmark on locally generated packets Fredrik Ax
2010-01-22 10:09 ` Patrick McHardy
2010-01-22 10:31 ` Fredrik Ax
2010-01-22 10:53 ` Patrick McHardy
2010-01-22 11:12 ` Fredrik Ax
2010-01-22 11:39 ` SOLVED: " Fredrik Ax
2010-01-22 11:41 ` Patrick McHardy
2010-01-22 12:31 ` Mart Frauenlob [this message]
2010-01-22 10:15 ` Fredrik Ax
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=4B599A92.1030900@chello.at \
--to=mart.frauenlob@chello.at \
--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