2

I have this in my interfaces file:

auto eth1
iface eth1 inet static
        address 20.135.251.218
        netmask 255.255.255.252
        up route add default gw 20.135.251.217 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?

2 Answers 2

2

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

1
  • 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, 2012 at 7:21
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .