linux routing rules

linux routing rules

Post by Moonstruc » Sun, 14 Sep 2003 23:05:18



I have a server with two routes to the internet.

Router A with a MAC address of 12:34:56:78:90:AB
and
Router B with a MAC address of CD:EF:12:34:56:78

It is a linux box. I want to force it to route return packets via the router
that the original packet came from. I was thinking something like:

Use iptables on the server to add an fwmark of 1 to in-bound packets
originating
from Router A
and an fwmark of 2 to packets originating from Router B

iptables -t mangle -A INPUT -m mac --mac-source 12:34:56:78:90:AB -j
MARK --set-mark 1
iptables -t mangle -A INPUT -m mac --mac-source CD:EF:12:34:56:78 -j
MARK --set-mark 2

then use iproute to add a routing rule based on the fwmark

ip rule add fwmark 1 table <something something something>
ip rule add fwmark 2 table <something something something>

What I don't know is...
does a return packet inherit an fwmark from the originating packet? If it
doesn't, then marking the in-bound packet is pointless.

Can someone that has wrestled with this problem give me a few pointers. This
must be a reasonably common need, is there a standard methodology for
dealing with it?

Thanks.

 
 
 

1. linux routing rules (based on session source)

I have a server with two routes to the internet.

Router A with a MAC address of 12:34:56:78:90:AB
and
Router B with a MAC address of CD:EF:12:34:56:78

The server is a linux box. I want to force it to route return packets via
the router
that the original packet came from. I was thinking something like:

Use iptables on the server to add an fwmark of 1 to in-bound packets
originating
from Router A
and an fwmark of 2 to packets originating from Router B

iptables -t mangle -A INPUT -m mac --mac-source 12:34:56:78:90:AB -j
MARK --set-mark 1
iptables -t mangle -A INPUT -m mac --mac-source CD:EF:12:34:56:78 -j
MARK --set-mark 2

then use iproute to add a routing rule based on the fwmark

ip rule add fwmark 1 table <something something something>
ip rule add fwmark 2 table <something something something>

What I don't know is...
does a return packet inherit an fwmark from the originating packet? If it
doesn't, then marking the in-bound packet is pointless.

Can someone that has wrestled with this problem give me a few pointers. This
must be a reasonably common need, is there a standard methodology for
dealing with it?

Thanks.

2. openlook window manager

3. routing mulitple providers, routes, rules, and masq

4. netstat -s -u does not display UDP stats

5. Operating System Sucks-Rules-O-Meter - Linux Rules,Rocks

6. ZIP parallel driver available for R2.2

7. Easy question: Can someone confirm my routing rules...

8. if your GCC (or binutils) gets signal 11, READ THIS!

9. ip route and ip rule questions

10. using fwmark routing rule on 2.2.x kernel

11. Route by IP address over tun0 - 'ip rule add from a.b.c.d'

12. mysteriously disappearing 'route' rule

13. iproute2: how to make rules/routes permanent ?