Two NICs, Two gateways, One Ubuntu

Soldato
Joined
13 Apr 2004
Posts
5,085
Location
London
I have two ISPs and two routers - 192.168.0.1 and 192.168.0.11.
My server box is permanently on but at the moment it is only connected to one router at a time. Is it possible to connect up both network cards in my server, each one with it's own gateway, and have one as a backup in case one gets disconnected?
 
Associate
Joined
19 Jun 2003
Posts
1,675
Location
West Yorks, UK
I tried doing exactly this a few weeks back and failed miserably when it came to routing the traffic. I ended up buying a Draytek router to load balance between the two connections and it works a treat.

Matt
 
Soldato
Joined
13 Apr 2004
Posts
5,085
Location
London
I have a little bit more information about my set up -
R1 (Netgear DG834N, ADSL Be Internet): 192.168.0.1
R2 (D-Link DIR655, Cable Virgin Media): 192.168.0.11

Ubuntu Box:
eth1 - 192.168.0.3, default gw 192.168.0.11
eth2 - 192.168.0.33, default gw 192.168.0.1

I hope that makes sense.
Now I want the Ubuntu box to mainly use the internet from 192.168.0.11.
I just want it to be connected to both ISPs because, well, why not? :)

That website looks very useful, I'll revise it when I get home. Cheers!
 
Soldato
Joined
15 Sep 2003
Posts
9,454
Why don't you set your linux box to load balance the connections? That was if one fails it will use the other anyway? The link provided shows you how to do that (at the bottom).
 
Associate
Joined
10 Sep 2007
Posts
679
There is a netgear router you can buy that has a WAN port for you Cable modem and a built in ADSL modem for your other conection, its apparently has a strong wifi signal too. It allows both conections to work together and gives fault tolerance. It a business class product so you will have to find it on line and it costs about £100. I will look up the exact model number and get back to you with it if its something you are interested in doing.
 
Soldato
Joined
13 Apr 2004
Posts
5,085
Location
London
I like my wireless-N too much, and between them my two routers cost about £200. I don't think I'm rich enough to dump them :)
4.2.1. Split access
The first is how to route answers to packets coming in over a particular provider, say Provider 1, back out again over that same provider.

Let us first set some symbolical names. Let $IF1 be the name of the first interface (if1 in the picture above) and $IF2 the name of the second interface. Then let $IP1 be the IP address associated with $IF1 and $IP2 the IP address associated with $IF2. Next, let $P1 be the IP address of the gateway at Provider 1, and $P2 the IP address of the gateway at provider 2. Finally, let $P1_NET be the IP network $P1 is in, and $P2_NET the IP network $P2 is in.

One creates two additional routing tables, say T1 and T2. These are added in /etc/iproute2/rt_tables. Then you set up routing in these tables as follows:

ip route add $P1_NET dev $IF1 src $IP1 table T1
ip route add default via $P1 table T1
ip route add $P2_NET dev $IF2 src $IP2 table T2
ip route add default via $P2 table T2
I tried doing this, but I didn't know what I would put as $P1_NET. Also I wasn't sure if all I was meant to do was add this in the bottom of /etc/iproute2/rt_tables or what.

Sorry to be a pain :(
 
Soldato
Joined
13 Apr 2004
Posts
5,085
Location
London
Here's my set-up:
http://www.clowneh.co.uk/network.txt
Code:
[email protected]:/home/clown# ip address list
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth2: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0e:a6:4c:6b:a9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.33/24 brd 192.168.0.255 scope global eth2
    inet6 fe80::20e:a6ff:fe4c:6ba9/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:0e:a6:54:77:da brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.3/24 brd 192.168.0.255 scope global eth1
    inet6 fe80::20e:a6ff:fe54:77da/64 scope link
       valid_lft forever preferred_lft forever
[email protected]:/home/clown# ip route show
192.168.0.0/24 dev eth2  proto kernel  scope link  src 192.168.0.33
192.168.0.0/24 dev eth1  proto kernel  scope link  src 192.168.0.3
169.254.0.0/16 dev eth2  scope link  metric 1000
default via 192.168.0.11 dev eth1  metric 100
default via 192.168.0.1 dev eth2  metric 100

I don't really know what I'm doing or what to change :)
 
Last edited:
Top Bottom