How to‎ > ‎

Set up network redundancy on CentOS

Everybody wants redundancy. It's important to keep a server online even if a network card, switch or a cable fails.
If you're on CentOS, it's pretty easy to configure a redundant network connection for the server. The common approach to this problem is 'Interface bonding'. There are multiple operational modes for interface bonding, but I'll show only what you need to configure so the second connection is in stand-by until the main connection fails.

The steps you need to take:
Enable bonding module loading
You need to modify /etc/modprobe.conf, so the bonding module will be loaded by ifup scripts

/etc/modprobe.conf changes required for interface bonding

# cat /etc/modprobe.conf
alias eth0 tg3
alias eth1 tg3
alias eth2 tg3
alias bond0 bonding
alias scsi_hostadapter cciss
alias scsi_hostadapter1 usb-storage

If you 'forget' to create this file, you'll get an error message similar to the following:

ifup bond0 error:

# ifup bond0
Device bond0 does not seem to be present, delaying initialization.



Define the bonding interface in /etc/sysconfig/network-scripts
Yo uneed to create at least one file for the bonding interface: /etc/sysconfig/network-scripts/ifcfg-bond0, with a contents similar to the following:

/etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
IPADDR=81.x.x.x
NETMASK=255.255.255.248
BROADCAST=81.x.x.y
NETWORK=81.x.x.z
IPV6INIT=yes
IPV6_AUTOCONF=yes
Of course, if you have a different setup, you may enable DHCP and/or different bonding module options here

Configure the bonding slaves (the physical interfaces)
For each physical interface which will be 'bond'-ed, you need to create (or modify) a /etc/sysconfig/network-scripts/ifcfg-ethX file, with a contents similar to:

/etc/sysconfig/network-scripts/ifcfg-ethX

# Broadcom Corporation NetXtreme BCM5704 Gigabit Ethernet
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:14:38:AA:AA:AA
ONBOOT=yes
MASTER=bond0
SLAVE=yes

After all the mentioned configuration, the redundant configuration can be brought online by the command:

# service network restart

# service network restart
Shutting down interface bond0:                             [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:                               [  OK  ]


Comments