其他分享
首页 > 其他分享> > Debian 16.04 配置双网卡绑定bond

Debian 16.04 配置双网卡绑定bond

作者:互联网

Debian 16.04 配置双网卡绑定bond

Debian 16.04 bonding多网卡配置

  1. 安装负载均衡软件 fenslave
root@ubuntu:~# apt-get install ifenslave
root@ubuntu:~# dpkg -l | grep ifenslave
ii  ifenslave                             2.7ubuntu1                                      all          configure network interfaces for parallel routing (bonding)
  1. 添加 bonding 模块,使之可以开机自动加载该模块
root@ubuntu:~# echo "bonding" >> /etc/modules
root@ubuntu:~# cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
bonding
root@ubuntu:~# modprobe bonding
root@ubuntu:~# lsmod | grep bonding
bonding 
  1. 编辑 /etc/network/interfaces 配置文件
root@ubuntu:~# vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

auto eth0                        #该网卡使用来远程使用的
iface eth0 inet static
        address 192.168.121.16
        netmask 255.255.255.0
        gateway 192.168.121.2

auto eth1                    #绑定的网卡eth1
iface eth1 inet manual       #最好设置为手动,设置为static可能会出问题
        bond-master bond0    #绑定的接口
        bond-primary eth1    #表示该网卡是主网卡,有流浪优先走该网卡

auto eth2                    #绑定的网卡eth2
iface eth2 inet manual
        bond-master bond0    #绑定的接口

auto bond0                   #绑定网卡名
iface bond0 inet static
        address 192.168.121.100
        netmask 255.255.255.0
        gateway 192.168.121.2
        bond-slaves none       #主备模式,没有从属网卡
        bond-mode 1            #1代表主备模式active-backup
        bond-miimon 200        #200毫秒监测一次网卡状态,如果有一条线路不通就切换另一条线路
root@ubuntu:~# vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface

auto eth0
iface eth0 inet static
        address 192.168.121.16
        netmask 255.255.255.0
        gateway 192.168.121.2

auto eth1
iface eth1 inet manual
        bond-master bond0

auto eth2
iface eth2 inet manual
        bond-master bond0

auto bond0
iface bond0 inet static
        address 192.168.121.100
        netmask 255.255.255.0
        gateway 192.168.121.2
        bond-slaves eth1 eth2        #添加两个从属网卡
        bond-mode 0         #0表示负载均衡模式
        bond-miimon 200
  1. 重启网络服务
root@ubuntu:~# systemctl restart networking
  1. 查看bond
root@ubuntu:~# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:57:67:25 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.16/24 brd 192.168.121.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe57:6725/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:57:67:39 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:57:67:39 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:57:67:39 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.100/24 brd 192.168.121.255 scope global bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe57:6739/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever

标签:00,bond0,16.04,Debian,网卡,ff,双网卡,inet,bond
来源: https://www.cnblogs.com/itwangqiang/p/14313584.html