Re: Routing tables and configuring gw

From: Alexander Clouter (alex_at_digriz.junk-this.org.uk)
Date: 02/22/04


Date: Sun, 22 Feb 2004 11:03:04 +0000

On 2004-02-20, john <qwejohn@hotmail.com> wrote:
> [snipped]
>
> But what I see is that after I bring up eth1, and type route, there is only
> one default gw line , which says it belongs to eth1. (the leftest
> column,IFace , is eth1 for all the rows; no eth0 at all (even eth0 is up).
> I see with tcpdump, that when I try to ping out, these atttempts are only
> done through eth1 (even that eth0 is up).
>
> I tried: (when they are both up)
> route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.254 dev
> eth0
> and got the follwoing error:
> SIOCADDRT: Network is unreachable
> (but there is a physical link from eth0 to 192.168.0.254).
>
> Any idea ?
>
> From what I googled on the net , it seems to me that it may be some problem
> of routing table ; But I could not find a solution. Any help will be
> appreciated.
>
I think you should actually think out loudly what the meaning of a _default_
gateway is. Once you computer has gone through the whole routing table to
find something suitable and in the end concludes it does not how to router
the traffic, the 'default' route says to the machine "if you do not have a
clue what to do with this packet, send it to this machine [the default
gateway] and it will probably know".

Having two default gateways is meaningless (ON THE SAME ROUTING TABLE) and
will break things, for example usually traffic leaves one card but comes back
on the other. As you are not load balancing the cards then it will always
pick the fist default gateway and all your traffic will leave across the
first network card.

You really should look at the relevent sections in the Advanced Routing
HOWTO[1] and assign a routing table to each card with source based routing.
You might also want to look into the load balancing elements (which should
also be applied on the default gateway).

A simpler alternative is that it sounds like you might be throwing in the
second network card for no real reason, and you would probably not be asking
the above question if you were aiming for load balancing. My hunch is that
what you really want to look at is IP Aliasing, remove the second network
card and simply type:

# ifconfig eth0 192.168.0.1 netmask 255.255.255.0
# ifconfig eth0:0 192.168.0.2 netmask 255.255.255.0
[ # ifconfig eth0:1 192.168.0.3.............. ] and so on if you want

have fun

Alex

[1] http://lartc.org/howto/lartc.rpdb.html



Relevant Pages

  • Re: Gateway strangeness?
    ... Are you sure the en0 adapter is the card that you plugged the ... > of itself as a gateway, but it's not because ... I've flushed the routing tables and ...
    (comp.unix.aix)
  • Re: NLB with 2 NICs
    ... I have 1 network card that connects to the rest of the network - ... (with gateway and dns etc set). ... I have a second card with IP ... >> I want to load balance with 2 NICs per server. ...
    (microsoft.public.windows.server.clustering)
  • simple question: dhcp & route add default gw ___
    ... add a 2nd network card. ... But how do I make eth1 my default gateway? ... "Advanced routing" one. ...
    (comp.os.linux.networking)
  • Re: Warning setting up TCP/IP
    ... Default Gateway). ... Remove any configuration settings from the card and ... Check if you still have problem with your network card. ...
    (microsoft.public.windows.server.general)
  • [SLE] Suse 9.1 Wireless Card
    ... is set up in yast, wep key, essid, static ip, gateway and dns. ... I can ping my ... When i use my other network card configured with dhcp everything works fine. ...
    (SuSE)