Channel Bonding เป็นวิธีการนำเอา network interface card หลายๆใบมารวมกันเพื่อให้สามารถ ขยาย bandwidth, fail-over interface, load balancing หรือ port trunking 802.3ad และยัง support VLAN หรือ 802.1q ได้อีกด้วย

Mode ต่างๆของการทำ bonding interface

  1. mode=0 round-robin policy เป็นการรับและส่งข้อมูลเป็นลำดับบนแต่ละ port lan โหมดนี้ใช้สำหรับ fault tolerance และ load balancing
  2. mode=1 (active-backup) เป็นวิธีการทำงานแบบ active และ backup โดยที่ interface ที่ถูกกำหนดให้เป็น master จะทำงานตามปกติ และอีก interface หนึ่งที่ถูกกำหนดให้เป็น slave จะไม่ทำงาน แต่เมื่อ interface ที่เป็น master เกิดใช้งานไม่ได้ interface ที่เป็น slave จะขึ้นมาทำให้ที่แทน โหมดนี้ใช้สำหรับ fault tolerance
  3. mode=2 (balance-xor) XOR policy ไม่ขอกล่าวถึง โหมดนี้ใช้สำหรับ fault tolerance และ load balancing
  4. mode=3 (broadcast) จะทำการ broadcast การส่งข้อมูลไปทุกๆ slave interface โหมดนี้ใช้สำหรับ fault tolerance
  5. mode=4 (802.3ad) IEEE 802.3ad Dynamic link aggregation หรือเรียกว่า link aggregation หรือ port trunking โดยเมื่อ set configure เป็น 802.3ad แล้วจะต้องใช้งานกับ switch ที่ set configure แบบ 802.3ad ด้วย สิ่งที่ต้องการเพิ่มเติม จะต้องใช้ ethtool จะต้อง support กับ driver เพื่อดึงค่า speed และ duplex ของทุกๆ slave port ด้วย
  6. mode=5 (balance-tlb หรือ Adaptive transmit load balancing) จะส่งข้อมูลออกไปในแต่ละ slave interface แต่เมื่อตอนรับข้อมูลจะรับข้อมูลที่ slave ที่ใช้งานอยู่ ถ้าเมื่อใดก็ตามที่ slave ที่รับข้อมูลเกิด fail slave ตัวอื่นจะนำ MAC address ของ slave ที่ fail มาใช้แทน โหมดนี้ใช้สำหรับ fault tolerance และ load balancing สิ่งที่ต้องการสำหรับ mode 5 คือ Ethtool support การตรวจสอบความเร็ว interface ของแต่ละ slave
  7. mode=6 (balance-alb หรือ Adaptive load balancing) เป็นโหมดในการทำ load balancing สำหรับข้อมูลในการรับและส่งสำหรับ IPV4 เท่านั้น ในการรับข้อมูลแบบ load balancing จะดักจับ ARP replies ที่จะส่งออกไปยังข้างนอกและทำการเขียนทับด้วย MAC address ของ slave interface ตัวใดตัวหนึ่ง โหมดนี้ใช้สำหรับ fault tolerance และ load balancing

miimon คือ การระบุความถี่ในการตรวจสอบ link เพื่อให้แน่ใจว่า link ของ NIC ต่างๆ ยังคง active อยู่ โดยหน่วยเป็น milliseconds แต่การจะใช้ option นี้ได้จะต้องตรวจสอบว่า NIC supoort MII tool หรือไม่ด้วยคำสั่ง

ethtool  | grep "Link detected:"

ตัวอย่างการ set bonding interface แบบ balance-tlb หรือ mode 5

แก้ไขไฟล์ /etc/modprobe.conf โดยเพิ่ม

alias bond0 bonding
options bond0 miimon=80 mode=5

รันคำสั่ง insmod เพื่อให้ add module

insmod bond0 miimon=80 mode=5

สร้างไฟล์ ifcfg-bond0 ใน /etc/sysconfig/network-scripts/ โดย copy ข้างล่างนี้ และแก้ไข ip address netmask และอื่นๆตามที่ต้องการ

DEVICE=bond0
IPADDR=
NETMASK=
NETWORK=
BROADCAST=
GATEWAY=
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

แก้ไขไฟล์ ifcfg-eth0 ที่ /etc/sysconfig/network-scripts/

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes

แก้ไขไฟล์ ifcfg-eth1 ที่ /etc/sysconfig/network-scripts/

DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes