All of lore.kernel.org
 help / color / mirror / Atom feed
* Routing Incoming and Outgoing Packets Differently
@ 2006-07-20 14:52 Jim Doble
  2006-07-20 18:34 ` Pascal Hambourg
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Doble @ 2006-07-20 14:52 UTC (permalink / raw)
  To: netfilter

Is there a way to use one set of routing rules for incoming packets and 
a different set of routing rules for outgoing packets? Or is there a way 
to set a socket option so that packets sent on a given socket are routed 
using a different routing table?

Jim Doble
Tavve SoftwareCompany


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Routing Incoming and Outgoing Packets Differently
  2006-07-20 14:52 Routing Incoming and Outgoing Packets Differently Jim Doble
@ 2006-07-20 18:34 ` Pascal Hambourg
  0 siblings, 0 replies; 2+ messages in thread
From: Pascal Hambourg @ 2006-07-20 18:34 UTC (permalink / raw)
  To: netfilter

Hello,

Jim Doble a écrit :
> Is there a way to use one set of routing rules for incoming packets and 
> a different set of routing rules for outgoing packets?

Yes, with advanced routing.

Quote from ip manpage (http://lartc.org/manpages/ip.txt) :

    ip rule add - insert a new rule
[...]
        iif NAME
               select the incoming device to match.  If the inter-
               face  is  loopback,  the  rule only matches packets
               originating from this host.  This  means  that  you
               may  create  separate  routing tables for forwarded
               and local packets and, hence, completely  segregate
               them.
[end of quote]

So you can create an alternate routing table for locally-generated 
packets. Incoming packets will use the default "main" routing table.

ip rule add iif lo lookup <output_table_number> prio 32765
ip route add <destination1> gw <gateway> table <output_table_number>
ip route add <destination2> dev <interface> table <output_table_number>
...

You need to have the following options enabled in your kernel to use 
this feature.
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-20 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-20 14:52 Routing Incoming and Outgoing Packets Differently Jim Doble
2006-07-20 18:34 ` Pascal Hambourg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.