Re: routing problem

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Meretei,

 : I've an interface (eth0) and its address (eg. 195.150.0.11) routed
 : throught 195.150.0.1  I made an alias 193.144.0.11 too (eth0:1) but I
 : have to route the second subnet trought an other router (193.144.0.1)
 :
 : the main problem is, that I cannot make two default routes... I dont
 : know really what to in this case

Damion was correct when he suggested that policy routing would be a good
solution for you.  He suggested reading lartc.org [0] and also a chapter
in my (incomplete) book; the chapter on routing [1].  Together these two
resources should give you a good idea of how the solution works.  Policy
routing leverages multiple routing tables and a policy database.  The
lookups in the policy database select the routing table to apply for a
particular packet.  With a careful design of your routing tables, you can
easily have two or more default routes, depending on the characteristics
of the outbound packet.

 : +--------+
 : | linux  | eth0    (195.150.0.11) -- [router: 195.150.0.1] -- INET
 : | router | eth0:1  (193.144.0.11) -- [router: 193.144.0.1] -- INET
 : +--------+

I assume that you are only showing us the networks connected to this
router, and that there are no others.  If that is the case, then my
following statements hold.

For you, the pitfall and difficulty will likely have more to do with
ensuring that the packets are sourced from the correct IP.  This will be
trivial if you are running servers on 195.150.0.11 and 193.144.0.11, but
may be more difficult if you are trying to select outbound path from
userspace.  This could depend on your application supporting the call to
bind to a particular IP.

In particular, you'll want to examine the kernel's rules for selecting a
source IP if it is not specified by the application [2].

If eth0 is your preferred link, then this should work for you as a
starting point:

  echo secondary >> /etc/iproute2/rt_tables
  ip rule add from 193.144.0.11 table secondary
  ip route flush table secondary
  ip route show table main | while read ROUTE ; do
      ip route add table secondary $ROUTE
  done
  ip route change default table secondary via 193.144.0.1

One other note.  The use of the term IP aliasing is archaic and
deprecated.  The command "ifconfig" displays "aliased" interfaces with
the old-style name "eth0:0", when, in fact, there is no such thing as an
alias under Linux.  This is immediately obvious when using the "ip
address" command line tool to list addresses associated with a particular
interface.

-Martin

 [0]  http://lartc.org/howto/lartc.rpdb.html#LARTC.RPDB.SIMPLE
 [1]  http://linux-ip.net/html/ch-routing.html
 [2]  http://linux-ip.net/gl/ip-cref/node155.html

-- 
Martin A. Brown --- SecurePipe, Inc. --- mabrown@xxxxxxxxxxxxxx

_______________________________________________
LARTC mailing list / LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux