06 Lesson 4 Phase 2 - RedHat and Mandrake

## Phase Two - For RedHat and Mandrake ##

# Step One - Hostname #

First thing we'll do is tell the computer what its own name is. This is the
name you though of in Step 1 of Phase 1.

The file we need to edit is

You either need to edit the existing line, or create a new one so that this
file contains the following entry:


You don't need to touch any other lines that might be there, but make sure
there is only one HOSTNAME entry.


Activate this setting by running the following two commands as root:

hostname <hostname>
su -

The hostname command manually sets the name of your computer to the value
<hostname>. Make sure its the same name you put in the network file!

Logging in again (the su -) makes the computer's new hostname appear in the
bash prompt.


# Step Two - IP Address and Gateway #

Now we enter the information gathered in Steps 2 and 4 of Phase 1. They're
combined because they both get entered into the same file.

The first thing we have to work out is the name of the interface we're
configuring, because that determines both the name of the file we need to
edit and one of the entries in that file.

If your computer only has one network card, then there's a 99.99% chance the
interface's name is eth0. However if your machine has multiple cards, (as is
possibly the case with the gateway machine), you'll first need to determine
which network interface is the one connected to your internal network. If
you're not sure how to do this, email and we can work it out.

For computers with one network card, the file you need is:

If you have multiple cards, you need to replace the eth0 at the end of the
above filename with the correct interface name. There's a chance it might be
eth0 anyway!

Once you've determined the correct file, it needs to contain all the
following entries. Make sure each of the variables (the words in capitals)
are listed only once, i.e. you can't have two lines beginning "DEVICE=". Any
time you see a # symbol (in any file), whether it be at the start of a line
or in the middle, all the text that follows is simply a comment and is
ignored by the computer. The comments below don't need to be typed in, but I
do hope you read them! The order in which the various entries appear is not

# Start of ifcfg-ethX -----------------------------------------------------

# The value you enter here must be the same as the last part of the name of
# the file you're editing. i.e., if you're editing ifcfg-eth0, then
# DEVICE=eth0. If you're editing ifcfg-eth2 then DEVICE=eth2, etc.

IPADDR=<IP address>
# This is the individual IP address you chose for this machine.

# This is the subnet netmask that goes with the range of IP addresses you're
# using. It's vitally important that all computers on your network have the
# same netmask.

# This is the IP address of the gateway machine from step 4. It too needs to
# be the same for all your computers. This line does not need to be included
# in the config file on the gateway machine itself, but it does no harm if
# you leave it in.

# End of ifcfg-ethX --------------------------------------------------------

It's quite possible the file you edit will contain additional lines added by
your distro's installer. Mandrake users especially will see this. This is
where you need to just look things over carefully. If you find you have
conflicting entries (such as two BOOTPROTO entries), comment out the
superfluous one by placing a # at the start of the line.

If you're curious as to what these entries mean (especially the extra ones
we haven't touched on) the file:
contains documentation about all the configuration files in /etc/sysconfig
and its subdirs.


Activate your network card with this new IP address using the following
commands (as root):

ifdown eth0
ifup eth0
ifconfig -a

Don't forget to substitute eth0 with the correct interface name if need be.

The first command halts eth0 and clears out its settings. The second command
starts eth0 working again with the new settings. The last command displays
the current settings of your network card. Use it to check everything is as
it should be.


# Step Three - Name Resolution #

In this, the last step, we use the data gathered at Step 3 of
Phase 1 to enable name resolution.

# Step 3 - Stage 1 - DNS Servers #

If your ISP dynamically assigns you an IP address when you connect to the
internet, do not complete this DNS Server stage on the gateway computer. You
still need to finish it on all the other machines on your network, but NOT
on the gateway. The file we edit in this stage is automatically updated on
your gateway machine every time you connect to the internet.

The file to edit (be careful of the correct spelling) is

All you need to do is add the following lines:

nameserver=<1st dns server>
nameserver=<2nd dns server>

You can add as many nameserver= lines as you have DNS servers.

The file may contain a few lines in addition to your nameserver= entries. In
all probability you can leave those lines alone, but as before, just use
your common sense, and ask if you're not sure.

# Step Three - Stage 2 - Computers on our Private Network #

In this last stage we edit the file:

We need to make two changes to this file.

The first is the addition of the computer's hostname to the line that begins
with the text This is the same hostname you entered into the
/etc/sysconfig/network file, which should also be the hostname that appears
in your bash prompt if you activated the changes made in Step 1.

This line is quite probably the very first line of the file. It
will already have some other names in it, including localhost. You need to
add your hostname to this line. It doesn't matter if it's the first name or
the last, but make sure it's on this line.

Your completed line should look similar to the one below. localhost localhost.localdomain <hostname>

The second change we need to make to the hosts file is to add the list of
computers and their IP addresses that we created in Step 3 of Phase 1. If
you want to do this the hard way, then you can type them all in manually,
copying from your diagram. Or we can do it the easy way, by simply appending
the mynet.txt file we created to the end of the hosts file.

If you choose the easy route, you can add the contents of your mynet.txt
file to the end of /etc/hosts by running the following command. Don't forget
to the include the full path to the mynet.txt file if needed.

cat mynet.txt >> /etc/hosts

The double >> is very important. If you only type one ">", then you will
wipe out your existing hosts file. You've got a backup right?


Neither the hosts file nor resolv.conf need activation. They get examined
anew each time a computer needs to look up a name.


Technically that's the end of Step Three. I suspect though a good many
people are wondering just how they're meant to get a copy of their mynet.txt
file to each machine on their network. You have several options, including
the following:

* Sneakernet. This is a fancy way of saying copy it onto a floppy disk.

* scp. Use scp (a component of ssh) to copy the file over the network.

* nc. (also called netcat). Another method of copying over the network.

If you need more detailed instructions on any of these methods, you know the
drill. ASK!


As promised, here is a copy of the config files on one of my machines. You
can see in ifcfg-eth0 the extra lines that Mandrake inserts.

[hamster@bob /]$ cat /etc/sysconfig/network
[hamster@bob /]$

[hamster@bob /]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
[hamster@bob /]$

[hamster@bob /]$ cat /etc/resolv.conf
search chello.nl
nameserver 212.142.bbb.xxx
nameserver 212.142.ccc.yyy
[hamster@bob /]$

[hamster@bob /]$ cat /etc/hosts localhost localhost.localdomain bob
# mynet.txt ------------------ constantinople mushu kokomo sadie tris sooty bob
[hamster@bob /]$


We're ready to move on to Phase Three, in which we test to see if our
network is working properly. There is no point at all commencing Phase Four
(setting up the gateway to allow our computers to access the internet) if
our computers can't communicate with each other.