giovedì 4 aprile 2013

Oracle Linux: NIC bonding

NIC bonding allow the use of multiple NICs for increased network performance or availability. Multiple NICs are combined into a single "network entity" called bond in which NICs can be added or removed.

So, let's start:

Create the bond alias. This alias will point to a network configuration file where we will define the properties of our bond like the IP address and bonding options.

[root@oracle ~]# nano /etc/modprobe.conf

add the following line into modprobe.conf

alias bond0 bonding

Now create the configuration file for interface bond0:

[root@oracle ~]# cd /etc/sysconfig/network-scripts/

[root@oracle network-scripts]# touch ifcfg-bond0

[root@oracle network-scripts]# nano ifcfg-bond0


Insert this in ifcfg-bond0 file:

DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=10.0.0.0
NETMASK=255.255.255.0
IPADDR=10.0.0.122
USERCTL=no
BONDING_OPTS="mode=1 miimon=100"


Where:

NETWORK=10.0.0.0 is the network class we are using.
IPADDR=10.0.0.122 is the IP address of this machine
BONDING_OPTS="mode=1 miimon=100" are the bonding options.

mode=1 is used for active backup policy which means that only one network adapter is active and the remaining are waiting for main NIC to fail in order to replace it.
Common values for "mode" are: 0 round robin and 1 active backup
miimon=100 is the frequency in milliseconds of MII link monitoring. 100ms is a suggested value.

bond0 configuration file is completed, now we need to edit configuration files for all NICs participating into this bond. For this guide I'm using only two NICs in bond0 so I have to edit only ifcfg-eth0 and ifcfg-eth1


[root@oracle ~]# nano /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=none
HWADDR=00:50:56:BF:00:25
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no


[root@oracle ~]# nano /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
BOOTPROTO=none
HWADDR=00:50:56:BF:00:34
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no


As you can see we configure all interfaces of the bond to be slaves using bond0 as master.

Restart network to apply changes:

[root@oracle ~]# service network restart
As for last step we need to add a default gateway for our machine:

[root@oracle ~]# /sbin/route add -net default gw 10.0.0.250
Try to ping an internet address, if ping echo reply returns correctly make permament this route adding previous command to rc.local file.

[root@oracle ~]# nano /etc/rc.local

Add:

/sbin/route add -net default gw 10.0.0.250


rc.local will be called each time the machine will startup.


That's all!!

Nessun commento:

Posta un commento