| Linux Newbie Guide VIII - Networking in Linux |
|
|
Page: 1/6 [Printable Version]
Setting up a network
Would it be worth it to set up my home network?
This is an excellent idea. It will let you use the machines that are in your
closet now because they were not powerful enough to run standalone. The
benefits include sharing hard drives, zipdrives, CDROMs, modem, printers, even
soundcards, running programs remotely (the text or graphics mode), browsing
the Internet on all computers at the same time over one phone connection. If
you ever lose control of your machine, you may also be able to shut it down
remotely and thus avoid possible problems.
How to set up my home network?
Hardware. Your hardware must be set up properly. Your network card
should have been set up during the initial RedHat installation. If you added
your card later, chances are it was autodetected and configured during a
subsequent bootup (by kudzu). If it wasn't, you may want to set
up your network card now. If you have more than one network card on your
computer, you will also need to set up the second cards manually, since Linux
will autodetect only 1 network card.
Under Linux, most drivers for network cards are implemented as modules. So
setting up a card manually involves just inserting the proper module with its
parameters. You don't need to recompile the kernel, nor even reboot your
computer (unless you have an uncommon card). To figure out what module(s) and
parameters you need, you may want to consult the documentations that comes
with the kernel source code:
less /usr/src/linux-2.4/Documentation/networking/net-modules.txt
If needed, you can list all the modules available for your kernel using
something like:
modeprobe -l | more
If you need more help, see the Linux Network Administrator Guide (file/usr/share/doc/LDP/nag
on your system or check http://metalab.unc.edu/mdw/index.html#guide).
This excellent guide is known as nag.
There are many ways of inserting a module into a kernel. For a network card,
the simplest is to start, as root, netconf and specify the module
name there. An alternative is to start an X-terminal, execute "su"
(to make yourself a root) and then run /usr/bin/kernelcfg
In most cases, you don't have to specify the parameters (IRQ and address)
for your module--the module will know what they should be. However, the
parameters were a problem during my setup of two network cards on one
computer--you must make sure that you don't have any hardware conflicts.
A common source of problems is that the card wants to configure on IRQ 5,
which is occupied by the SoundBlaster, or IRQ 3 which conflicts with the
second serial port (COM2, cua1, ttyS1). Inspecting the files /proc/interrupts,
/proc/ioport and reading bootup messages may help.
For example, my WD8013 card (same as SMC Elite and SMC Elite plus,
according to nag) runs under IRQ 10 (set by a jumper on the card and I
specified the IRQ in the kernel module setup), under the address 0x300 and
uses the "WD" module. My "SMC EtherEZ" card (no
jumper settings on the card) runs under IRQ 9, address 0x240 and uses
"SMC EtherEZ" module. Please make sure you don't omit the leading
"0x" in the address--it means "hexadecimal" and must be
there else the number will be interpreted as decimal.
After the module is inserted, you may want to inspect the file /proc/modules
to see if the module is indeed loaded (or run lsmod as root).
The module configuration file is /etc/modules.conf so if you
encounter difficulties (for example, I had difficulty removing modules
inserted by mistake), just edit and adjust this file manually, e.g.,
using pico.
Network. After setting up the network cards and connecting the
cables, set up the network by running (as root):
netconf
This program has help! netconf can also be run under GUI, but I
did not really try it. If you need more understanding of how networking works,
you may want to read the previously mentioned nag. Also, reading this material
may be of help: http://ieee.uow.edu.au/~mjp16/wylug-netlinux/notes.html.
It also contains very clear examples on how to set up a small office network
that, like our home setup, has only part-time connection to the outside world.
How and what to fill up in netconf depends on your network. You
surely want to fill up "Basic Host Information" (enable the first
ethernet interface, eth0, fill in the name, aliases and IP number of
your local computer) and the "Information About Other Hosts" (names,
aliases and IPs of other computers on your home network). This information
goes to the files: /etc/hosts and /etc/sysconfig/network, so
you may want to inspect these files and adjust them manually.
When setting up the network, don't mess up with the "loopback
driver" which has the IP 127.0.0.1. It is always there--it is the
IP through which the computer talks to itself.
If you don't have an IP address (as will typically be the case for a home
network with no permanent connection to the outside world), you may want to
invent one. It does not matter very much what it is since when connecting to
the outside world by your modem, you will be dynamically allocated an IP
address (a machine can have many IP addresses at the same time). Your invented
IP must be formally correct and the net mask must match the class of the
network (class A, B or C). See the chapter on IP addresses in the
already mentioned Network Administrator Guide (nag) (/usr/doc/LPD/nag
on your system, or if you don't have it, download it now from http://metalab.unc.edu/mdw/index.html#guide.
For a home network, you might want to invent a class C network (up to 254
machines, the smallest) IP number which has the first three digits between 192
to 223. The last three digits identify the machine on your class C network and
must be between 1 and 254 (don't use 0, it means "whole network" or
255 which is the "broadcast address"). The middle two sets of
digits can be anything from 0 to 255. Thus 223.223.223.1 is the first machine
on the class C network 223.223.223.0 (the last zero signifies the whole
network), with the broadcast address 223.223.223.255. The network mask for a
class C network is always 255.255.255.0 (unless you subdivide your network
into smaller "subnet", which is not discussed here).
Rather than completely inventing an IP number, it might be safer/better to
use one of the numbers reserved for "private networks". For me, the
IP number 192.168.1.1 works just fine.
Typically, the first machine on a network is the one that is expected to have
the connection to the outside world (since it was connected first, but there
is no standard for that). So, I filled up the GATEWAY to xxx.xxx.xxx.1 (my
first machine) on all machines, except for the machine xxx.xxx.xxx.1, where I
left this field blank. Actually, although I left the field blank, netconf
inserted the gateway 0.0.0.0 into the /etc/sysconf file. This
was a source of an annoying error message during the loading of the network
card on the bootup. To get rid of the message, I edited /etc/sysconfig/network
and set it to something like this:
GATWAYDEV=
GATEWAY=
[You don't want a gateway on your ethernet interface on this machine if it
does not lead to the outside world. The ppp interface on this first machine
will be set up as a default gateway once you connect through your modem, e.g.
using kppp.]
The name of a computer is entirely arbitrary--the main user normally chooses a
short word s/he likes. The domain name of the home network is also entirely
arbitrary, unless you have a permanent connection in which case a domain name
is registered to you. Try to invent something that does not exist
yet--it could make your life easier once you have a permanent connection.
As for the DNS server (also called "named"), RedHat 5.2 and 6.0
comes with DNS preinstalled as "caching-only" so it is easy to
configure as such. You may also choose not to use DNS at all--if DNS is
looking up an "outside" server and can't find it, it can be a real
show-stopper (the machine can appear to be hanged for up to a few minutes).
To use local DNS, the "named" service must be enabled-- check this
by running setup. To set up the caching-only DNS, fill up the
appropriate boxes in netconf. E.g., I filled "nameserver
1" to my first machine on all computers (I entered the loopback address
127.0.0.1 on the machine xxx.xxx.xxx.1, and the proper xxx.xxx.xxx.1 address
on all other machines).
No routes to other networks and hosts were required in my network, since I
don't have other local networks. So I left this field blank.
Other than setting up the hardware correctly and filling up the info under netconf
on each computer, as described above, I did not have to do anything on the
standard RedHat to get my network working.
Reboot all computers one by one in any order (this is not necessary, but won't
hurt you) and watch the boot messages (if they scroll too fast off screen, use
<Shift><PgUp> to scroll up, or use dmesg from the
command line to view them later). Did your cards configure correctly?
Use the command route (as root) to see if the eth0 interface is
running. Use the ping command to test the connections between
individual machines. Try to telnet your local computer to see
it the loopback-only (lo) interface works:
telnet name_of_the_machine_you_are_sitting_at
After a successful login, you can exit the telnet session by typing
exit
Finally, try to telnet another computer on your network:
telnet name_of_a_remote_machine
If this works on all machines, your eth0 network interface is set up.
After setting up your ppp and connecting to your Internet Service Provider
(ISP), you will have another network interface (ppp0) and then will be able to
telnet any machine in the world.
|