By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
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:
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
|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 subnet 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:
cd /etc/sysconfig/network-scripts zip –r network_dir * mkdir /backup cp network_dir.zip /backup
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:
cd /etc/sysconfig/network-scripts cp /backup/network_dir.zip /etc/sysconfig/network-scripts unzip -o network_dir.zip /sbin/service network reload
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.
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.
and make the changes as below:
DEVICE=eth0 HWADDR=00:01:11:11:11:11 ONBOOT=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=192.168.1.215 GATEWAY=192.168.1.1
DEVICE=eth0:1 HWADDR=00:01:11:11:11:11 ONBOOT=yes TYPE=Ethernet NETMASK=255.255.255.0 IPADDR=192.168.1.244 GATEWAY=192.168.1.1
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.
Once back at command prompt, do:
/sbin/ifconfig eth1 hw ether 00:CC:CC:CC:CC:CC
/sbin/ifconfig eth1 up