Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this in my interfaces file:

auto eth1
iface eth1 inet static
        up route add default gw dev eth1 metric 1

If I run ifconfig eth1 down, the default gateway is removed from the routing table. But when I do ifconfig eth1 up, the default gateway is not added to the routing table. I have two default gateways with different metric, so only the other gateway appears in the routing table. I have set gc_timeout as 10. I'm trying implemet a solution mentioned in the answer to this question. how can I automatically add the default gateway when I bring up the interface?

share|improve this question

You can better do this load balancing among multiple internet connections by using Advanced Routing (iproute2) feature of Linux Kernel.

By default, there are three routing tables maintained by linux kernel. You can view these three by using the following command:

$ ip rule list
0: from all lookup local
32766: from all lookup main
32767: from all lookup default

When you give route -n command it gives the entries of the main routing tables.

You can view the entries in each of these three routing tables by using the command:

$ ip route list tables local
$ ip route list tables main
$ ip route list tables default

You can add a new routing table let's say pradeep by using following set of commands:

$ echo 200 pradeep >> /etc/iproute2/rt_tables
$ ip rule add from all table pradeep

I think you want to do exactly the same discussed here: Routing for multiple providers

share|improve this answer
I want to have a failover or fallback setup and not load balancing. When the main route fails, it should automatically change over to backup link. – nixnotwin Apr 10 '12 at 7:21

Well, I have just finished writing some lines about dead gateway detection and neighbour unreachability for multi-homed routing setups in another question. Maybe my answer sheds more light on the topic.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.