Tuesday, October 4, 2011

How to making Linux multihomed to connect to 2 ISP

To make my Ubuntu Server on more robust I have connected it to 2 ISP so that I can have redundant last mile. Also one of my ISP gives me unlimited bandwidth while the other is costlier but more reliable.

To make your linux server multihomed, I am assuming that you have atleast 2 network interfaces. In my case both are ethernet (eth0 and eth1)

Make sure both the networks are working individually up by setting it on /etc/network/interface
sudo vi /etc/network/interface

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        metric 100

auto eth1
iface eth1 inet static
        metric 200

Now if you go to your terminal, you should be able to
>ip route show dev eth1  proto kernel  scope link  src dev eth0  proto kernel  scope link  src
default via dev eth0  metric 100
default via dev eth1  metric 200

With this if your eth0 goes down, your eth1 will take over and vice-versa.
But this is still a long way from making your network multihoned where your can do load balancing.

All you need to do is to add  multihop route in your /etc/rc.local
ip route append default scope global nexthop via dev eth0 weight 5 nexthop via dev eth1 weight 1

No comments:

Post a Comment