网卡配置bond mode 4,前提交换机端口开启静态LACP模式

1、安装 ifenslave

ifenslave作用是网卡的负载均衡

  1. apt-get install ifenslave -y

2、编辑 /etc/network/interfaces 配置文件

  1. root@fvts-host-cn-alpha:~# cat /etc/network/interfaces
  2. # This file describes the network interfaces available on your system
  3. # and how to activate them. For more information, see interfaces(5).
  4. source /etc/network/interfaces.d/*
  5. # The loopback network interface
  6. auto lo
  7. iface lo inet loopback
  8. # The primary network interfacez
  9. auto eno1np0
  10. iface eno1np0 inet static
  11. bond-master bond4
  12. auto eno2np1
  13. iface eno2np1 inet static
  14. bond-master bond4
  15. auto bond4
  16. iface bond4 inet static
  17. address 10.0.30.74/24
  18. gateway 10.0.30.1
  19. bond-mode 802.3ad #网卡模式 mode 4
  20. bond-slaves eno1np0 eno2np1 #所绑定的网卡
  21. bond-miimon 100 #网卡状态监测周期100ms
  22. bond-downdelay 200 #网卡down时间
  23. bond-updelay 200 #网卡up时间

3、开机自动加载bonding模块

  1. root@fvts-host-cn-alpha:~# vim /etc/modules
  2. # /etc/modules: kernel modules to load at boot time.
  3. #
  4. # This file contains the names of kernel modules that should be loaded
  5. # at boot time, one per line. Lines beginning with "#" are ignored.
  6. bonding #添加这行

4、重启服务器

  1. reboot

验证

Debian配置网卡bonding - 图1

  1. root@fvts-host-cn-alpha:~# cat /proc/net/bonding/bond4
  2. Ethernet Channel Bonding Driver: v5.10.0-0.bpo.4-amd64
  3. Bonding Mode: IEEE 802.3ad Dynamic link aggregation
  4. Transmit Hash Policy: layer2 (0)
  5. MII Status: up
  6. MII Polling Interval (ms): 100
  7. Up Delay (ms): 0
  8. Down Delay (ms): 0
  9. Peer Notification Delay (ms): 0
  10. 802.3ad info
  11. LACP rate: slow
  12. Min links: 0
  13. Aggregator selection policy (ad_select): stable
  14. System priority: 65535
  15. System MAC address: bc:97:e1:02:26:10
  16. Active Aggregator Info:
  17. Aggregator ID: 1
  18. Number of ports: 2
  19. Actor Key: 15
  20. Partner Key: 1089
  21. Partner Mac Address: 88:40:33:59:f1:a0
  22. Slave Interface: eno1np0
  23. MII Status: up
  24. Speed: 10000 Mbps
  25. Duplex: full
  26. Link Failure Count: 0
  27. Permanent HW addr: bc:97:e1:02:26:10
  28. Slave queue ID: 0
  29. Aggregator ID: 1
  30. Actor Churn State: none
  31. Partner Churn State: none
  32. Actor Churned Count: 0
  33. Partner Churned Count: 0
  34. details actor lacp pdu:
  35. system priority: 65535
  36. system mac address: bc:97:e1:02:26:10
  37. port key: 15
  38. port priority: 255
  39. port number: 1
  40. port state: 61
  41. details partner lacp pdu:
  42. system priority: 32768
  43. system mac address: 88:40:33:59:f1:a0
  44. oper key: 1089
  45. port priority: 32768
  46. port number: 3
  47. port state: 61
  48. Slave Interface: eno2np1
  49. MII Status: up
  50. Speed: 10000 Mbps
  51. Duplex: full
  52. Link Failure Count: 0
  53. Permanent HW addr: bc:97:e1:02:26:11
  54. Slave queue ID: 0
  55. Aggregator ID: 1
  56. Actor Churn State: none
  57. Partner Churn State: none
  58. Actor Churned Count: 0
  59. Partner Churned Count: 0
  60. details actor lacp pdu:
  61. system priority: 65535
  62. system mac address: bc:97:e1:02:26:10
  63. port key: 15
  64. port priority: 255
  65. port number: 2
  66. port state: 61
  67. details partner lacp pdu:
  68. system priority: 32768
  69. system mac address: 88:40:33:59:f1:a0
  70. oper key: 1089
  71. port priority: 32768
  72. port number: 4
  73. port state: 61