Open Source

Expand your network with multiple NICs in Linux

Learn the rudimentary steps for setting up multiple network cards in a Linux system.


An operating system’s ability to support multiple network interface cards (NICs) is critical in many environments. It allows for future expansion without the need to add new servers, and it lets an administrator break up a network into smaller pieces without the need for a router. Most every operating system can support multiple NICs. It’s simply a matter of figuring out how to set them up.

Linux includes ways to support multiple NICs via its flexible utilities. I’ll show you how to set up multiple NICs in a Linux server. I’ll be using Red Hat Linux 7.3 for my examples, although the steps will work for other versions of Linux as well.

Red Hat Linux 7.3
I’ll assume that you have a working Red Hat Linux 7.3 server and that you’ve installed the adapter and rebooted the machine. I’ll be using the Linux netconfig command line tool for this step, although you can also use an X interface such as Gnome or KDE. I don’t generally run an X interface on any of my Linux servers, although I do install it initially and run it when someone wants to quickly and easily make system configuration changes. Other ways to handle these types of tasks would be to directly edit the configuration files or use a tool such as Webmin.

The boot-up process
During boot time, Red Hat Linux 7.3 checks for new hardware and, if it finds it, starts Kudzu, the hardware discovery utility. Assuming that you’re using a Plug and Play-capable network adapter, Kudzu will tell you the brand and model of the adapter it finds. At times, it may tell you it has found a totally different brand and model of card—this is due to the fact that NIC makers often don’t make their own chipsets but use a third-party solution instead. If Kudzu misidentifies your NIC, don’t worry—chances are you won’t run into any problems.

Card configuration
When Kudzu starts, it will tell you what it found and then give you three options—configure, ignore, or do nothing. If you choose to do nothing, you’ll get the same screen the next time you boot. If you ignore the device, it will be present but not configured. The option that I’ll be working with is to configure the device so that the system can use it.

After you choose the configure option, Kudzu asks if you want to set up a network. An affirmative answer starts netconfig, a Linux utility that you can use to configure your networking parameters. Netconfig asks if you want to use DHCP. If you choose to, you can enter the IP address, network mask, gateway, and a name server (Figure A). For this example, I chose not to enter name server information since it’s already present in the first Ethernet adapter’s configuration.

Figure A
Netconfig configuration screen for the new adapter


Once you’ve set up this information, you’ll have two working network adapters on your Linux machine. As with Windows, you should be careful about assigning more than one default gateway since it can confuse the server when it needs to send traffic out beyond one of its locally attached networks. I’ve done so here only to show you the network configuration. On a production server, I’d only have one default gateway.

Other ways to modify Linux network parameters
One of the things that people like about Linux is the fact that it allows you to modify system settings in various ways. You can use a graphical interface or a command line tool, or you can directly edit the various configuration files with nothing more than a text editor. If you decide that you want to quickly modify your networking configuration under Red Hat Linux 7.3, you can do so by editing certain script files in /etc/sysconfig/network-scripts.

For the example that I showed you, there are two files in this directory that you can edit to change your networking parameters—ifcfg-eth0 and ifcfg-eth1. These two files correspond to the name that Linux assigns to the hardware device, and they contain script commands that configure the device. See Table A for the listing for ifcfg-eth0, which is the first network adapter in the machine that was configured at the same time Linux was installed.
Table A
DEVICE='eth0'
This is the device name assigned by Linux. I do not recommend changing it.
BOOTPROTO='none'
This can be one of none, bootp, or DHCP. If you are using static addressing, use none. If you choose DHCP or bootp, you will not need any further options.
BROADCAST='192.168.1.255'
This is the broadcast address that the device will use. This is always the very last IP address in a range and is not useable by any devices.
IPADDR='192.168.1.210'
This is the IP address that you want to assign to the device.

NETMASK='255.255.255.0'

Every IP address needs a subnet mask. This is where you assign it.
NETWORK='192.168.1.0'
Like the broadcast address, you cannot assign this address to any devices, as it is an identifier that lets the network adapter know which network it is present on.
ONBOOT='yes'
Do you want the network adapter to be started when the system starts?
GATEWAY='192.168.1.1'
Which local device is the default gateway for the network?
TYPE='Ethernet'
What type of card is this? Since I am working with Ethernet, this is the option I need to use (and it fits since the device name is 'eth').
USERCTRL='no'
Defines whether or not non-root users are allowed to modify the networking parameters for this device.
Text-based networking configuration

Skinning the cat in multiple ways
One of the great things about Linux is its chameleon-like quality. It has the ability to be most things for most people—mail server, Windows domain controller, Web server, database server, and much more. With its ability to support multiple network adapters, it can act in other capacities, such as a router. It can also support the binding of multiple NICs for increased bandwidth, which can help you run especially resource-hungry applications on your network.

 

Editor's Picks

Free Newsletters, In your Inbox