Debian 9.4 多網卡鏈路聚合bond配置


Debian 9.4 多網卡鏈路聚合bond配置

安裝ifenslave

  1. ifenslave 的作用是網卡的負載均衡
root@debian:~# apt-get install ifenslave
root@debian:~# dpkg -l | grep ifenslave
ii  ifenslave                             2.9                                         all          configure network interfaces for parallel routing (bonding)

編輯 /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

auto eth0                    #eth0作為遠程使用的IP地址
iface eth0 inet static
      address 192.168.121.94
      netmask 255.255.255.0
      gateway 192.168.121.2

auto bond0
iface bond0 inet static
      address 192.168.121.100
      netmask 255.255.255.0
      gateway 192.168.121.2
      bond-mode 0
      bond-slaves eth1 eth2
      bond-miimon 100
      bond-downdelay 200
      bond-updelay 200

auto eth1                   #eth1和eth2作為需要綁定的網卡,不需要給定IP地址
iface eth1 inet static

auto eth2
iface eth2 inet static
  • 注釋
auto bond0
iface bond0 inet static
      address 192.168.121.100
      netmask 255.255.255.0
      gateway 192.168.121.2
      bond-mode 0             #網卡模式(0代表負載均衡模式;1代表主備模式)
      bond-slaves eth1 eth2   #所綁定的網卡
      bond-primary eth1       #設置綁定的主網卡,有流量優先走eth1(當模式為1)
      bond-miimon 100         #網卡狀態監測周期100ms
      bond-downdelay 200      #網卡down時間
      bond-updelay  200       #網卡up時間
  • bond-mode 模式列表
0:      balance-rr       負載均衡模式
1:      active-backup    主備模式
2:      balance-xor      異或策略
3:      broadcast        廣播策略
4:      802.3ad          動態鏈接聚合
5:       balance-tlb      適配器傳輸負載均衡
6:      balance-alb      適配器負載均衡

開機自動加載bonding模塊

  1. 編輯 /etc/modules 文件
root@debian:~# vim /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@debian:~# reboot
  • 使用 systemctl restart networking.service 這個命令重啟網絡服務會一直報錯,不知道為啥,重啟就好了

查看

root@debian:~# 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:38:1f:4c brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.94/24 brd 192.168.121.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe38:1f4c/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:38:1f:56 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:38:1f:56 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:38:1f:56 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:fe38:1f56/64 scope link tentative dadfailed 
       valid_lft forever preferred_lft forever


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM