Description
RHEL allows admins to bind multiple network interfaces together into a single channel using the bonding kernel module and special network interface called a channel bonding interface. Channel bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy. The bonded interfaces are depends upon bonding interface parameter i.e. mode. It sets a round-robin policy for fault tolerance and load balancing.
Sample Diagram for NIC Bonding:
Step1: Here, we would like to configure the channel bonding i.e. bond0 with interfaces eth1 and eth2
Requirements:
2 NIC cards
1 Static IP and netmask value
Step2: Kernel module Configuration:
To make channel bonding interface (i.e. bond0) to be valid, the kernel module must be loaded. To ensure that module is loaded when the channel bonding interface is brought up, create a new file as a root named bonding.conf file in the /etc/modeprobe.d/ directory.
# echo "alias bond0 bonding">/etc/modprobe.d/bonding.conf
# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
2 NIC cards
1 Static IP and netmask value
Step2: Kernel module Configuration:
To make channel bonding interface (i.e. bond0) to be valid, the kernel module must be loaded. To ensure that module is loaded when the channel bonding interface is brought up, create a new file as a root named bonding.conf file in the /etc/modeprobe.d/ directory.
# echo "alias bond0 bonding">/etc/modprobe.d/bonding.conf
# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
NOTE: We can name this file anything as we like, but it should be end with .conf extention
Step3: Creating Channel Bonding Interface:
To create channel bonding interface, we need to create a bonding configuration file on/etc/sysconfig/network-scripts/ directory called ifcfg-bondN, where N is the number for the interface, such as “0”
# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=10.32.112.228
NETMASK=255.255.254.0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=0 miimon=1000"
To create channel bonding interface, we need to create a bonding configuration file on/etc/sysconfig/network-scripts/ directory called ifcfg-bondN, where N is the number for the interface, such as “0”
# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=10.32.112.228
NETMASK=255.255.254.0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=0 miimon=1000"
For DHCP Device
# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=dhcp
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=0 miimon=1000"
BOOTPROTO=dhcp
ONBOOT=yes
USERCTL=no
BONDING_OPTS="mode=0 miimon=1000"
NOTE: Here, mode=0 indicates that it sets a round robin policy for fault tollerence and load balancing
Miimon specifies (in milliseconds) how often MII link monitoring occurs. It always verifies that the NIC is active or not. To verify that the driver for particular NIC supports the MII tool, we have to use below command
# ethtool eth0|grep "link detected:"
Link detected: yes
Step4: Configuring Network Interfaces
Once we created the channel bonding interface i.e. bond0, the network interfaces to be bound together must be configured by adding the MASTER and SLAVE directives to their configuration files. The configuration files for each of the channel bonded interfaces can be nearly identical.
# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:03:23:17
MASTER=bond0
SLAVE=yes
USERCTL=no
# cat /etc/sysconfig/network-scripts/ifcfg-eth2
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:03:23:21
MASTER=bond0
SLAVE=yes
USERCTL=no
Step5: Enabling Bonding Interface
# ifconfig bond0 up ==>To enable and fetch the ipaddres from configuration file
(or)
# ifconfig bond0 10.32.112.228 netmask 255.255.254.0 up
To check existing bonds:
# cat /sys/class/net/bonding_masters
bond0
To view an existing mode:
# cat /sys/class/net/bond0/bonding/mode
balance-rr 0
To check an existing miimon:
# cat /sys/class/net/bond0/bonding/miimon
1000
To verify bonding:
# ifconfig -a
bond0 Link encap:Ethernet HWaddr 00:0C:29:03:23:17
inet addr:10.32.112.228 Bcast:10.32.113.255 Mask:255.255.254.0
inet6 addr: fe80::20c:29ff:fe03:2317/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:46470 errors:0 dropped:0 overruns:0 frame:0
TX packets:380 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5120536 (4.8 MiB) TX bytes:48723 (47.5 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:03:23:0D
inet addr:10.32.113.13 Bcast:10.32.113.255 Mask:255.255.254.0
inet6 addr: fe80::20c:29ff:fe03:230d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26938 errors:0 dropped:0 overruns:0 frame:0
TX packets:3154 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2939471 (2.8 MiB) TX bytes:435014 (424.8 KiB)
Interrupt:67 Base address:0×2000
eth1 Link encap:Ethernet HWaddr 00:0C:29:03:23:17
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:22015 errors:0 dropped:0 overruns:0 frame:0
TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2395814 (2.2 MiB) TX bytes:20245 (19.7 KiB)
Interrupt:67 Base address:0×2080
eth2 Link encap:Ethernet HWaddr 00:0C:29:03:23:17
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:24455 errors:0 dropped:0 overruns:0 frame:0
TX packets:242 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2724722 (2.5 MiB) TX bytes:28478 (27.8 KiB)
Interrupt:75 Base address:0×2400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3454 errors:0 dropped:0 overruns:0 frame:0
TX packets:3454 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4147201 (3.9 MiB) TX bytes:4147201 (3.9 MiB)
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:03:23:0d brd ff:ff:ff:ff:ff:ff
inet 10.32.113.13/23 brd 10.32.113.255 scope global eth0
inet6 fe80::20c:29ff:fe03:230d/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:03:23:17 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:03:23:17 brd ff:ff:ff:ff:ff:ff
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue
link/ether 00:0c:29:03:23:17 brd ff:ff:ff:ff:ff:ff
inet 10.32.112.228/23 brd 10.32.113.255 scope global bond0
inet6 fe80::20c:29ff:fe03:2317/64 scope link tentative
valid_lft forever preferred_lft forever
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-2 (October 7, 2008)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 1000
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:0c:29:03:23:17
Slave Interface: eth2
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 00:0c:29:03:23:21
NOTE: To change an existing mode and miimon values (optional)
# ifconfig bond0 down
# echo 100 > /sys/class/net/bond0/bonding/miimon
# echo 6 > /sys/class/net/bond0/bonding/mode
# ifconfig bond0 up
Bonding modes:
balance-rr or 0: Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.
active-backup or 1: Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.
balance-xor or 2: Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface
broadcast or 3: Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
802.3ad or 4: Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant
balance-tlb or 5: Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave
balance-alb or 6: Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPV4 traffic. Receive load balancing is achieved through ARP
No comments:
Post a Comment