Re: Multiple external interfaces

From: sean (sean_at_fredcom.com)
Date: 03/18/04


Date: Thu, 18 Mar 2004 14:56:23 -0500


First, you should only need to enter a gateway once for the default
routing table (unless you are routing to two different gateways, but I
am assuming that you are not).

It sounds like you need to set up routing tables to have one segment get
routed differently then another.

Assuming that your default route is set to go out eth0, and you want
10.0.1.0/24 to go out eth1

ip rule add from 10.0.1.0/24 table "altroute"
ip route add default via [ip-address-of-eth1] dev eth1 table "altroute"
ip route flush cache

This will send out anything from the 10.0.1.0/24 net though the second
nic. If eth1 is a DHCP address you can do something like this to get
the IP address that is assigned to it:

IP=`/sbin/ifconfig eth1|grep "inet addr"| \
        cut -f 2 -d ":"|cut -f 1 -d " "`

Crude, but effective.

Now $IP will hold the IP address of that ethernet device.

Is it possible that you can setup a secondary IP address on the same NIC
with DHCP a second time? That way you have eth0 and eth0:0 with two
separate IP addresses, and you can tailor you iptables rules to NAT to
each IP address instead of using the ip rule and route commands.

As for the pinging from the outside could it be that the return ping is
exiting the wrong nic and getting dropped or ignored? Have you tried a
tcpdump on each interface while attempting this to see how the server is
responding to the pings?

LeX wrote:
> Hi there,
>
> After months of tinkering I'm desparate, I don't know what to do. I hope
> someone out here knows what to do, this is my problem:
>
> My Linux server (Debian 3 stable) has 1 internal network adapter and 2
> external adapters. I want to route the traffic from my 10.0.0.x subnet
> via one interface, and the traffic from my 10.0.1.x subnet via the other
> one. Both external interfaces are connected to a single cable modem
> (Which supports up to 8 network cards) and have both an ip address in
> the same subnet with the same gateway. If I put both cards in diffrent
> computers they work perfectly, but in the Linux box only one of them
> works (The one initialised first). If I do "ifup extA && ifup extB" only
> extA can be pinged from the outside, if i do "ifup extB && ifup extA"
> only extB can be pinged from the outside. Whatever I try I can't get
> both of them to work at the same time. Am I missing something or is this
> just impossible with Linux?
>



Relevant Pages

  • Re: Routing Problem
    ... Subject: Routing Problem ... each with a different subnet. ... it should use the second default gateway. ... > routers configured on multiple interfaces connected to two or more ...
    (freebsd-questions)
  • Re: AIX 1.3 Failures and Fables
    ... DESTINATION GATEWAY FLGS REFCNT USE INTERFACE ... Is my interpretation of the AIX 1.3 #man route correct? ... Manually manipulates the routing tables. ... Is the destination host or network. ...
    (comp.sys.ibm.ps2.hardware)
  • Re: AIX 1.3 Failures and Fables
    ... I don't know if 1.3 has SMIT or its equivalent but there should be some way to add a default gateway which is your router. ... Is my interpretation of the AIX 1.3 #man route correct? ... Manually manipulates the routing tables. ... Is the destination host or network. ...
    (comp.sys.ibm.ps2.hardware)
  • Re: AIX 1.3 Failures and Fables
    ... I don't know if 1.3 has SMIT or its equivalent but there should be some way to add a default gateway which is your router. ... is: route add 1.2.3.4 gateway ... Manually manipulates the routing tables. ... Is the destination host or network. ...
    (comp.sys.ibm.ps2.hardware)
  • Re: 2 different routes
    ... you're trying to route a subnet you're in through ... its gateway -- that won't work the way you expect it to. ... gateway of the secondary public network for things that came in on that ...
    (comp.unix.bsd.freebsd.misc)