Setting up a network with Red Hat Enterprise Linux 4.0

Learn the basics of Linux networking tasks, like backing up configuration files, and progress to spoofing MAC addresses and subinterfacing using Red Hat Enterprise Linux 4.0.

More on RHEL networking:
RHEL4 and Windows integration using Samba-3

Installing, configuring firewalls, packet filtering in RHEL4

In general, one of the hardest things about Linux is learning is the command-line interface (CLI). Linux servers aren't usually equipped with click and go menus like Windows. But this allows you to have a more robust and tailor-made system when using RHEL servers. With the knowledge and ability to effectively configure and customize a RHEL network service, you'll be able to order to start a network or prevent and/or lessen down-time. In this tip, you'll learn the basics of booting a Linux network and move on to turning one physical interface (NIC) into two logical interfaces, also referred to as called sub-interfacing.

Once the Linux machine has been successfully booted, the network service is usually already started. If not, it can be started by doing:

/sbin/service network start

This will launch the interface scripts that are held in /etc/sysconfig/network-scripts. You can view which interfaces are up or down, and some more statistics on each interface by typing:


Additionally, the network service can be stopped (shutting down all interfaces) or reloaded (reloading the configuration files from /etc/sysconfig/network-scripts) by using:

/sbin/service network stop


/sbin/service network reload

All configuration files can be edited via script directory. You can edit them by with the command:

cd /etc/sysconfig/network-scripts

Each interface has its own configuration file. For example, interface eth0's configuration file will be named ifcfg-eth0 under this directory. If you're modifying the eth0 interface, then do the following:

vi ifcfg-eth0
'vi' is a text-editor that comes standard with most RHEL installations.

An example of the file that you just opened is as follows:

# Broadcom Corporation|NetXtreme BCM5704 Gigabit Ethernet

Code Description
DEVICE=eth0 This shows you what this devices name is.
HWADDR=00:01:23:45:67:89 This is the MAC address of this interface.
ONBOOT=yes When the network service is started, should this interface be brought up?
TYPE=Ethernet What kind of interface is this?
NETMASK= The subnet mask of the network that this interface lies on.
IPADDR= This is the interface's IP address.
GATEWAY= This is the gateway IP address where all of the data goes when the destination packet isn't bound for a computer on the local network.

Note: Any line that begins with # is a comment in a configuration file -- this is standard with most scripts with Linux, not just the network scripts. This comment describes driver it's using to run this interface.

Backing up configuration files

Like any other configuration files stored on your Linux system, the network configuration files need to be backed up. Therefore, if there are any problems your network connection can be restored shortly. I recommend making a backup right now, especially while practicing your network service skills.

You can make a backup with this by typing:

cd /etc/sysconfig/network-scripts
zip –r network_dir *
mkdir /backup
cp /backup

To sum up the steps for making a backup:

  1. cd /etc/sysconfig/network-scripts takes you to the directory where the configuration files are stored.
  2. zip –r network_dir *zips each file under the current directory and sends it to a zip file called ""
  3. mkdir /backup creates a new directory called /backup at the root of your Linux machine.
  4. Finally, cp /backup creates a copy of in the /backup directory.

To restore from a previous backup, do the following:

cd /etc/sysconfig/network-scripts
cp /backup/ /etc/sysconfig/network-scripts
unzip -o
/sbin/service network reload

To sum up the steps for restoring from a previous backup:

  1. cd /etc/sysconfig/network-scripts went into the correct directory
  2. cp /backup/ /etc/sysconfig/network-scriptscopied the into the proper directory.
  3. unzip -o unzipped the .zip file, overwriting the current configuration files .
  4. Finally, /sbin/service network reload reloaded the configuration files to be ran.


For the rest of this tip, let's assume that we're working with the eth0 interface.

Have you ever needed one physical interface to have more than one IP address? Here's how! First, you'll need to go into the network-scripts directory (cd /etc/sysconfig/network-scripts) and create a backup. The instructions on how to do this is in the first part of backing up configuration files.

Once you've created a backup, type:

cp ifcfg-eth0 ifcfg-eth0:1

This is simply creating a new configuration file for your sub-interface.

Then do:

vi ifcfg-eth0:1

and make the changes as below:





In order to make the changes, hit Insert on your keyboard and then modify what's needed. The changes made are with the device name (identifier) and with the IP address. Once the changes are made, you can then save the new configuration file by doing CTRL+C and then typing "wq."

Then simply restart, or reload the network service, and you should see that it also sees eth0:1 as a separate physical device now.

MAC address spoofing

With Linux, you are easily able to spoof your MAC address to whatever you'd like it to be, as long as it's a technically legal MAC address. You can't have a MAC address of XX:XX:XX:XX:XX:XX!

When your network service is started and the eth0 interface is up, do the following:

cd /etc/sysconfig/network-scripts
/sbin/ifconfig eth0 down
vi ifcfg-eth0

Change the MAC address field to what you'd like the interface's new MAC address-to-be. Save the file by typing CTRL+C, "wq" and hitting Enter.


Before: HWADDR=00:01:23:45:67:89


Once back at command prompt, do:

/sbin/ifconfig eth1 hw ether 00:CC:CC:CC:CC:CC

Then do:

/sbin/ifconfig eth1 up

This was first published in January 2007

Dig deeper on Linux management and configuration



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: