Home > Enterprise Linux Tips > Administrator > Setting up a network with Red Hat Enterprise Linux 4.0
Enterprise Linux Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ADMINISTRATOR

Setting up a network with Red Hat Enterprise Linux 4.0


Austin Jorden
01.18.2007
Rating: -4.23- (out of 5)


Enterprise Linux headlines
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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:

/sbin/ifconfig

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

or

/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=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:

  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 "network_dir.zip"
  3. mkdir /backup creates a new directory called /backup at the root of your Linux machine.
  4. 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:

  1. cd /etc/sysconfig/network-scripts went into the correct directory
  2. cp /backup/network_dir.zip /etc/sysconfig/network-scriptscopied the network_dir.zip into the proper directory.
  3. unzip -o network_dir.zip unzipped the .zip file, overwriting the current configuration files .
  4. 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:

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:

Before:

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

After:

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.

Example:

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

After: HWADDR=00:CC:CC:CC:CC:CC

Once back at command prompt, do:

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

Then do:

/sbin/ifconfig eth1 up

Rate this Tip
To rate tips, you must be a member of SearchEnterpriseLinux.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Red Hat Enterprise Linux (RHEL)  (SearchEnterpriseLinux.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts