现在的位置: 首页 > 综合 > 正文

Create NIC Channel Bonding in RedHat/CentOS/Fedora

2014年01月27日 ⁄ 综合 ⁄ 共 3976字 ⁄ 字号 评论关闭

Create NIC Channel Bonding in RedHat/CentOS/Fedora

Channel Bonding enables two or more network interfaces to act as one, simultaneously increasing the bandwidth and providing redundancy. This is a great way of achieving redundancy to a server. If one physical
NIC is down or unplugged, it will automatically move resource to other
NIC card. Channel bonding will work with the help of bonding driver in kernel. This post guides you through how to create NIC / Channel Bonding in
RedHat,
CentOS
and Fedora Linux.

Create Channel Bonding in Linux
<img class="size-medium wp-image-637" src="http://www.tecmint.com/wp-content/uploads/2012/07/Channel-Bonding-in-Linux-300x210.jpg" alt="Create Channel Bonding in Linux" width="300" height="210" />

Create Channel Bonding in Linux

How to Create NIC Channel Bonding in
RedHat,
CentOS
and Fedora

Step 1: Creating Bonding Channel

As a root, create a new file name bonding.conf in the
/etc/modprobe.d/ directory. Name can be anything you like as long as it ends with a
.conf extension. Insert the following line in this new file.

alias bond0 bonding

For each configured channel bonding interface, there must be a corresponding entry in your new
/etc/modprobe.d/bonding.conf file.

Step 2: Creating Channle Bonding Interface

To create a channel bonding interface, create a file in the /etc/sysconfig/network-scripts/ directory called
ifcfg-bond0. The following is a sample channel bonding configuration file. (Note : IP Address may differ in your environment.)

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.8
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

Step 3: Configuring Channel Bonding Interface

After the channel bonding interface is created, 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. For example, if two Ethernet interfaces are being channel bonded, both
eth0 and eth1 may look like the following example. Edit physical interface card details as under.

For eth0

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

For eth1

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

The above directives are self explanatory for many system admin, however, let me explain to newbie.

  1. DEVICE: Indicates what is the device name
  2. USERCTL: Indicates that can user control this device(here its no)
  3. ONBOOT:  Indicates that at the boot time do this device should be up?
  4. MASTER: Is this device has master? Then what it is(here its bond0)
  5. SLAVE: Is this device acting as slave?
  6. BOOTPROTO: What about getting IP Address from DHCP? It’s set to none which indicate it’s a static IP)

Step 4: Restarting Network Service

Restart the network service and see the output of ifconfig.

# service network restart
[root@tecmint network-scripts]# ifconfig

bond0     Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          inet addr:192.168.1.8  Bcast:172.16.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe69:31c4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
          RX packets:19676 errors:0 dropped:0 overruns:0 frame:0
          TX packets:342 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1623240 (1.5 MiB)  TX bytes:42250 (41.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:10057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:832257 (812.7 KiB)  TX bytes:22751 (22.2 KiB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:9620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:791043 (772.5 KiB)  TX bytes:20207 (19.7 KiB)
          Interrupt:19 Base address:0x2080

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:104 (104.0 b)  TX bytes:104 (104.0 b)

抱歉!评论已关闭.