How to configure eth1 to be a failsafe system for eth0.
When eth0 is down eth1 goes up, and when eth0 is up eth1 goes down
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityHow to configure eth1 to be a failsafe system for eth0.
When eth0 is down eth1 goes up, and when eth0 is up eth1 goes down
What you are looking to set up is called Network Bonding.
This is also called "port trunking or link aggregation (which) means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these."
In this case, you will want to set up a Mode 1 active-backup bonding configuration.
Install package to allowing interface bonding**
First, you will need to install the ifenslave package which allows interfaces to be added and removed from a bonding group.
Install the ifenslave package from the Ubuntu Software Center:
or, you can install the package from the command line:
sudo apt-get install ifenslave-2.6
Modify config to load bonding module
Next, you will modify your /etc/modules
file to ensure that the
bonding module is loaded.
sudo gedit /etc/modules
and add the following line to the bottom of the file:
bonding mode=active-backup miimon=100 max_bonds=2 primary=eth0
The miimon option tells how often to monitor(in milliseconds) the interface for failure and can be adjusted as needed.
load the bonding kernel module:
sudo modprobe bonding
Define the bond group
Finally, you will define the bond group in the file /etc/network/interfaces
and restart the networking service.
sudo gedit /etc/network/interfaces/
auto bond0
iface bond0 inet static
address 192.168.1.10
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
bond-slaves none
bond-mode 1
bond-miimon 100
post-up ifenslave bond0 eth0 eth1
pre-down ifenslave -d bond0 eth0 eth1
auto eth0
iface eth0 inet manual
bond-master bond0
bond-primary eth0 eth1
auto eth1
iface eth1 inet manual
bond-master bond0
bond-primary eth0 eth1
Restart the networking service
sudo service networking restart
Note: This does not allow for bonding between two different network types (i.e. You cannot bond between an ethernet card and a wireless connection.)
Also, this has nothing to do with multi-homing between two ISPs and is beyond the scope of this question.
References:
https://help.ubuntu.com/community/UbuntuBonding#Ethernet_Bonding_modes
You need network bonding.
From https://help.ubuntu.com/community/UbuntuBonding:
Bonding, also called port trunking or link aggregation means combining several network interfaces (NICs) to a single link, providing either high-availability, load-balancing, maximum throughput, or a combination of these.
Install ifenslave (sudo apt-get install ifenslave-2.6
), and configure /etc/network/interfaces
like this:
auto eth0
iface eth0 inet manual
auto eth1
iface eth1 inet manual
auto bond0
iface bond0 inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.254
slaves eth0 eth1
bond-mode active-backup