Hack and / - Bond, Ethernet Bond

Configure Ethernet bonding and get a license to kill a network interface without any downtime.
For Your Files Only

The next step is to configure the bonding module with the bonding mode you want to use, along with any other options you might want to set for that module. On a Red Hat system, you will edit either /etc/modprobe.conf (for a 2.6 kernel) or /etc/modules.conf (for an older 2.4 kernel). On a Debian-based system, edit or create the /etc/modprobe.d/aliases file. In either case, add the following lines:

alias bond0 bonding
options bonding mode=1 miimon=100

The alias line will associate the bond0 network interface with the bonding module. If you intend on having multiple bonded interfaces (such as on a system with four or more NICs), you will need to add an extra alias line for bond1 or any other interfaces. The options line allows me to set my bonding mode to 1 as well as set miimon (how often the kernel will check the link state of the interface in milliseconds).

On Your Distribution's Network Service

Like with module configuration, different distributions handle network configuration quite differently, and that's true for bonded interfaces as well. So, at this point, it's best if I describe each system separately.

From Red Hat with Love

Red Hat network configuration is managed via files under /etc/sysconfig/network-scripts. Each interface has its own configuration file preceded by ifcfg-, so that the configuration for eth0 can be found in /etc/sysconfig/network-scripts/ifcfg-eth0. To configure bonding, you simply can use the basic network settings you would have for your regular interface, only now they will be found in ifcfg-bond0:

DEVICE=bond0
NETMASK=255.255.255.0
GATEWAY=192.168.19.1
BOOTPROTO=static
IPADDR=192.168.19.64
HOSTNAME=goldfinger.example.net
ONBOOT=yes

Next, each interface you want to use for bond0 needs to be configured. In my case, if I wanted to bond eth0 and eth1, I would put the following into ifcfg-eth0:

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

and the following into ifcfg-eth1:

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

Finally, type service network restart as root to restart your network service with the new bonded interface. From this point on, you can treat ifcfg-bond0 as your main configuration file for any network changes (and files like route-bond0 to configure static routes, for instance). To make this even easier for you, I've included a script for Red Hat users that automates this entire process. Run the script with the name of the bonded interface you want to use (such as bond0), follow it with the list of interfaces you want to bond, and it will set up the modules and network interfaces for you automatically based on the configuration it finds in the first interface (such as eth0) that you list. So, for instance, to set up the above configuration, I would make sure that ifcfg-eth0 had the network settings I wanted to use, and then I would run the script shown in Listing 1.

______________________

Kyle Rankin is a systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Good Article

earlan's picture

Wew, good work :D
Keep posting . . .
Hack? Are hack legal?
I think No . . .
http://earlan.info/

White Paper
Fabric-Based Computing Enables Optimized Hyperscale Data Centers

Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.

Learn More

Sponsored by AMD

White Paper
Red Hat White Paper: Using an Open Source Framework to Catch the Bad Guy

Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6

Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.

Learn more about catching the bad guy in this free white paper.

Learn More

Sponsored by DLT Solutions