In scenarios where a Linux system has multiple network interfaces, maintaining internet connectivity even if one interface goes down becomes crucial. This blog post will guide you through the process of setting up a routing table with multiple gateways and metrics to ensure a seamless switch between interfaces.

Identifying Gateways

Before configuring the routing table, identify the IP addresses of the gateways associated with each network interface. This information will be used to set up default routes with different metrics.

Setting Up the Routing Table

  1. Open the routing table configuration file, typically located at /etc/network/interfaces or /etc/sysconfig/network-scripts/route-interface.
  2. Add the default routes with distinct metrics for each interface. Here’s an example for eth0 and ppp0 in the /etc/network/interfaces file:
auto eth0
iface eth0 inet dhcp
    post-up route add default via <eth0_gateway> metric 100

auto ppp0
iface ppp0 inet ppp
    post-up route add default via <ppp0_gateway> metric 200

Replace <eth0_gateway> and <ppp0_gateway> with the actual gateway IP addresses for eth0 and ppp0.

Applying the Changes

After editing the configuration file, restart the networking service or the system for the changes to take effect:

sudo service networking restart

Alternatively, manually add the routes using the ip route command:

sudo ip route add default via <eth0_gateway> metric 100
sudo ip route add default via <ppp0_gateway> metric 200

Testing the Configuration

Disconnect one of the interfaces and verify that the system maintains internet connectivity. The configured routing table should automatically switch to the other route with a higher metric.


Configuring a robust routing table with multiple gateways and metrics on a Linux system is a valuable strategy to ensure continuous internet connectivity, even in the event of one interface going down. By following these steps, you can enhance the reliability of your network configuration and minimize downtime. Adjust the metric values according to your specific requirements and network conditions.