Quantcast
Channel: GoLinuxHub
Viewing all articles
Browse latest Browse all 392

How to do Ethernet/NIC bonding/teaming in Red Hat Linux

$
0
0
NICteaming/bonding is used mostly in scenarios where you cannot afford to loose connectivity due to ethernet failover issues and also it has many other advantages like to distribute bandwidth, fault tolerance etc

Let us start with the configuration steps
Make sure you have two(at least) physical Ethernet cards in your Linux machine.

Edit the configuration files of both the Ethernet cards with the options as shown below
# less /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
MASTER=bond0
USERCTL=no
SLAVE=yes
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes

# less /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no

Create a new file inside /etc/sysconfig/network-scripts/ifcfg-bond0 with the parameters as shown below
# less /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.0.100
NETWORK=192.168.0.1
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

And finally append/make these following changes in below mentioned file as shown
# vi /etc/modprobe.conf
alias bond0 bonding
options bond0 mode=1 miimon=100


Here, you can use different values for mode and miimon

What is mode in NIC Teaming in Linux?

You can configure NIC Teaming for various purposes. So while configuration you will have to specify the purpose you want to utilise NIC Teaming.
Here are the list of available options
mode=0 : Load Balancing
mode=1 : Fault Tolerance


balance-rr: Frames are transmitted in a round-robin fashion without hashing, to truly load balance.

802.3ad: This mode is the official standard for link aggregation, and includes many configurable options for how to balance the traffic.

balance-xor: Traffic is hashed and balanced according to the receiver on the other end. This mode is also available as part of 802.3ad.

broadcast: This mode is not really link aggregation - it simply broadcasts all traffic out both interfaces, which can be useful when sending data to partitioned broadcast domains for high availability. If using broadcast mode on a single network, switch support is recommended.

balance-tlb: Outgoing traffic is load balanced, but incoming only uses a single interface. The driver will change the MAC address on the NIC when sending, but incoming always remains the same.

balance-alb: Both sending and receiving frames are load balanced using the change MAC address trick.

What is miimon in NICTeaming?

Specifies (in milliseconds) how often MII link monitoring occurs. This is useful if high availability is required because MII is used to verify that the NIC is active. To verify that the driver for a particular NIC supports the MII tool, type the following command as root:
# ethtool <interface_name> | grep "Link detected:"

# ethtool eth0 | grep "Link detected:"
       
Link detected: yes

# ethtool eth1 | grep "Link detected:"
        Link detected: yes

So for our demo purpose we will use mode 1 make NIC bonding for Fault Tolerance

Now time to load the bonding module
# modprobe bonding
Restart the network interface to make the changes affect
# service network restart
Verify if your configuration has worked properly using below command
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode:
fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 5f:5g:56:3v:23:54

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 4f:76:23:v4:76:f6

Check your network status

# ifconfig
bond0     Link encap:Ethernet  HWaddr R5:4G:45:6H:14:54
          inet addr:
192.168.0.100 Bcast:192.168.0.1  Mask:255.255.255.0
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:675166546 errors:0 dropped:0 overruns:0 frame:0
          TX packets:60123345 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:717558660669 (668.2 GiB)  TX bytes:680121390699 (633.4 GiB)

eth0      Link encap:Ethernet  HWaddr 5F:5G:56:3V:23:54
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:675130834 errors:0 dropped:0 overruns:0 frame:0
          TX packets:601230970 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:717553120481 (668.2 GiB)  TX bytes:680121390699 (633.4 GiB)
          Interrupt:169 Memory:96000000-96012800

eth1      Link encap:Ethernet  HWaddr 4F:76:23:V4:76:F6
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:35302 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5540188 (5.2 MiB)  TX bytes:0 (0.0 b)
          Interrupt:122 Memory:94000000-94012800


Let me know your success and failures

Follow the below links for more tutorials

Multiple connections to a server or shared resource by same user
How to extract files to different directory using tar in Unix/Linux
How to preserve Symbolic links with tar command in Unix/Linux
How to give permission to user to run some commands in Linux
How to set environment (PATH) variable permanently in Linux
How to mount windows share on linux


Viewing all articles
Browse latest Browse all 392

Trending Articles