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:
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:
or
All configuration files can be edited via script directory. You can edit them by with the command:
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:
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=255.255.255.0 The su...
To continue reading for free, register below or login
To read more you must become a member of SearchEnterpriseLinux.com
');
// -->

bnet mask of the network that this interface lies on.
IPADDR=192.168.1.154 This is the interface's IP address.
GATEWAY=192.168.1.1 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:
To sum up the steps for making a backup:
- cd /etc/sysconfig/network-scripts takes you to the directory where the configuration files are stored.
- zip –r network_dir *zips each file under the current directory and sends it to a zip file called "network_dir.zip"
- mkdir /backup creates a new directory called /backup at the root of your Linux machine.
- Finally, cp network_dir.zip /backup creates a copy of network_dir.zip in the /backup directory.
To restore from a previous backup, do the following:
To sum up the steps for restoring from a previous backup:
- cd /etc/sysconfig/network-scripts went into the correct directory
- cp /backup/network_dir.zip /etc/sysconfig/network-scriptscopied the network_dir.zip into the proper directory.
- unzip -o network_dir.zip unzipped the .zip file, overwriting the current configuration files .
- Finally, /sbin/service network reload reloaded the configuration files to be ran.
Sub-interfacing
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:
This is simply creating a new configuration file for your sub-interface.
Then do:
and make the changes as below:
Before:
After:
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:
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.
Example:
Before: HWADDR=00:01:23:45:67:89
After: HWADDR=00:CC:CC:CC:CC:CC
Once back at command prompt, do:
Then do: