Hack and / - Bond, Ethernet Bond
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).
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.
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.
Listing 1. Bond Script for Red Hat Users
# bond bond0 eth0 eth1
#!/usr/bin/perl
# bond -- create a bonded interface out of one or
# more physical interfaces
# Created by Kyle Rankin
#
my $bond_interface = shift;
my @interfaces = @ARGV;
my $network_scripts_path = '/etc/sysconfig/network-scripts/';
my $bond_mode=1;
my $bond_miimon=100;
my $bond_max=2;
usage() unless (@ARGV);
if($#interfaces < 1){
usage("ERROR: You must have at least 2 interfaces to bond!");
}
system("/etc/init.d/network stop");
config_bond_master($bond_interface, $interfaces[0]);
foreach(@interfaces){
config_bond_slave($bond_interface, $_);
}
config_modules($bond_interface, $bond_miimon, $bond_mode);
system("/etc/init.d/network start") or die
↪"Couldn't start networking: $!\n";
sub usage
{
$error = shift;
print "$error\n" if($error);
print "Usage: $0 bond_interface interface1 interface2 [...]\n";
print "\nbond_interface will use the network
↪settings of interface1\n";
exit
}
sub config_bond_master
{
my $bond_interface = shift;
my $main_interface = shift;
my $netconfig_ref = get_network_config($main_interface);
open CONFIG, "> $network_scripts_path/ifcfg-$bond_interface"
↪or die "Can't open
↪$network_scripts_path/ifcfg-$bond_interface: $!\n";
print CONFIG "DEVICE=$bond_interface\n";
foreach(keys %$netconfig_ref){
unless($_ eq "HWADDR" || $_ eq "DEVICE"){
print CONFIG "$_=$$netconfig_ref{$_}\n";
}
}
close CONFIG;
}
sub config_bond_slave
{
my $bond_interface = shift;
my $slave_interface = shift;
my $netconfig_ref = get_network_config($slave_interface);
open CONFIG, "> $network_scripts_path/ifcfg-$slave_interface"
↪or die "Can't open
↪$network_scripts_path/ifcfg-$slave_interface: $!\n";
print CONFIG <<"EOC";
DEVICE=$slave_interface
USERCTL=no
ONBOOT=yes
MASTER=$bond_interface
SLAVE=yes
BOOTPROTO=none
EOC
if($$netconfig_ref{'HWADDR'}){
print CONFIG "HWADDR=$$netconfig_ref{'HWADDR'}";
}
}
# This subroutine returns a hash with key-value pairs matching
# the network configuration for the interface passed as an
# argument according to the configuration file in
# /etc/sysconfig/network-scripts/ifcfg-interface
sub get_network_config
{
my $interface = shift;
my %netconfig;
open(CONFIG, "$network_scripts_path/ifcfg-$interface")
↪or die "Can't open
↪$network_scripts_path/ifcfg-$interface: $!\n";
while(<CONFIG>)
{
chomp;
($key, $value) = split '=';
$netconfig{uc($key)} = $value;
}
close CONFIG;
return \%netconfig;
}
sub config_modules
{
my $bond_interface = shift;
my $bond_miimon = shift;
my $bond_mode = shift;
my $bond_options_configured = 0;
my $bond_alias_configured = 0;
if(-f "/etc/modprobe.conf"){ # for 2.6 kernels
$module_config = "/etc/modprobe.conf";
}
else {
$module_config = "/etc/modules.conf";
}
open CONFIG, "$module_config" or die
↪"Can't open $module_config: $!\n";
while(<CONFIG>){
if(/options bonding/){ $bond_options_configured = 1; }
if(/alias $bond_interface bonding/){
↪$bond_alias_configured = 1; }
}
close CONFIG;
open CONFIG, ">> $module_config" or die
↪"Can't open $module_config: $!\n";
unless($bond_alias_configured)
{
print CONFIG "alias $bond_interface bonding\n";
}
unless($bond_options_configured)
{
print CONFIG "options bonding
↪miimon=$bond_miimon mode=$bond_mode max_bonds=$bond_max\n";
}
close CONFIG;
}
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.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Linux Systems Administrator
- Introduction to MapReduce with Hadoop on Linux
- RSS Feeds
- Tech Tip: Really Simple HTTP Server with Python
- Weechat, Irssi's Little Brother
- Help with Designing or Debugging CORBA Applications
- Senior Perl Developer
- Reply to comment | Linux Journal
29 min 58 sec ago - Welcome to 1998
1 hour 18 min ago - notifier shortcomings
1 hour 42 min ago - heroku?
3 hours 19 min ago - Android User
3 hours 20 min ago - Reply to comment | Linux Journal
5 hours 13 min ago - compiling
8 hours 3 min ago - This is a good post. This
13 hours 16 min ago - Great, This is really amazing
13 hours 18 min ago - These posts are really good
13 hours 19 min ago




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