如何使用eth1作为eth0的故障保护系统?

如何将eth1配置为eth0的故障安全系统。

eth0下降时, eth1上升,当eth0上升时, eth1下降

您要设置的内容称为网络绑定 。

这也称为“ 端口中继链路聚合 (这意味着)将多个网络接口(NIC)组合到单个链路,提供高可用性,负载平衡,最大吞吐量或这些的组合。”

在这种情况下,您需要设置模式1活动备份绑定配置。

  1. 安装包以允许接口绑定**

    • 首先,您需要安装ifenslave软件包,该软件包允许在绑定组中添加和删除接口。

    • 从Ubuntu软件中心安装ifenslave软件包:

    通过软件中心安装

    • 或者,您可以从命令行安装包:

      sudo apt-get install ifenslave-2.6

  2. 修改config以加载绑定模块

    接下来,您将修改/etc/modules文件以确保加载了绑定模块。

    sudo gedit /etc/modules并将以下行添加到文件的底部:

     bonding mode=active-backup miimon=100 max_bonds=2 primary=eth0 

    miimon选项指示监视(以毫秒为单位)接口失败的频率,并可根据需要进行调整。

  3. 加载绑定内核模块:

     sudo modprobe bonding 
  4. 定义债券组

    最后,您将在文件/etc/network/interfaces定义绑定组并重新启动网络服务。

    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 
  5. 重新启动网络服务

    sudo service networking restart

注意:这不允许在两种不同的网络类型之间进行绑定(即,您无法在以太网卡和无线连接之间进行绑定。)

此外,这与两个ISP之间的多宿主无关,超出了本问题的范围。

参考文献:

https://help.ubuntu.com/community/UbuntuBonding#Ethernet_Bonding_modes

http://ubuntuforums.org/showthread.php?t=1888967

http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-modules-ethernet.html#s3-modules-bonding-directives

你需要网络绑定 。

来自https://help.ubuntu.com/community/UbuntuBonding :

绑定,也称为端口中继或链路聚合,意味着将多个网络接口(NIC)组合到单个链路,提供高可用性,负载平衡,最大吞吐量或这些的组合。

安装ifenslave( sudo apt-get install ifenslave-2.6 ),并配置/etc/network/interfaces如下:

 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