From: terryd@extro.ucc.su.oz.au (Terry Dawson)
Subject: Linux NET-2 HOWTO (part 1/3)
Date: Fri, 18 Nov 1994 17:11:12 GMT [thread overview]
Message-ID: <NET-2-HOWTO.1-3506.785178649@cs.cornell.edu> (raw)
Archive-name: linux/howto/networking/part1
Last-modified: 18 Nov 94
Linux NET-2/NET-3 HOWTO
Terry Dawson, terryd@extro.ucc.su.oz.au
v2.7, 08 Oct 1994
This document aims to describe how to obtain, install and configure
the Linux NET-2 and NET-3 networking software. Some answers to some of
the more frequently asked questions are also included.
1. Introduction.
This is the Linux NET-2-HOWTO. This document is a complete rewrite of
the earlier NET-FAQ, and of the subsequent NET-2-HOWTO versions 1.0+,
for the new NET-2 and NET-3 tcp/ip networking code for Linux kernels
1.0 and above.
1.1. Changes from the previous release.
Additions:
Added details of the new ARCNet driver - thanks Avery.
Added tcpdump location details
Corrections:
Fixed symlink to dip and chmod problem - thanks Lamar.
Updated Matt Dillon's slip management suite version
1.2. A brief development history of Linux Networking.
Ross Biro <biro@yggdrasil.com> wrote the original kernel based
networking code for Linux. He used ethernet drivers written by Donald
Becker <becker@cesdis1.gsfc.nasa.gov>, a slip driver written by
Laurence Culhane <loz@holmes.demon.co.uk>, and a D-Link driver by
Bj0rn Ekwall <bj0rn@blox.se>.
The further development of the Linux networking code was later taken
up by Fred van Kempen <waltje@hacktic.nl>, who took Ross's code and
produced the NET-2 release of network code. NET-2 went through a
number of revisions until release NET-2d, when Alan Cox
<iialan@iifeak.swan.ac.uk> took Fred's NET-2d code and set about
debugging the code with the aim of producing a stable and working
release of code for incorporation into the standard kernel releases.
This code was called NET-2D(ebugged), and has been incorporated into
the standard kernel releases since some time before Linux vers 1.0 was
released.
PPP support was added by Michael Callahan, <callahan@maths.ox.ac.uk>
and Al Longyear, <longyear@netcom.com>, originally as patches to the
kernel, and in later releases as an option.
Fred continued developing his kernel network code, and produced
NET-2E. A reference for it if you are interested in looking at Fred's
new work is listed later on in this document.
With the release of Linux vers 1.0, Linus made a decision to continue
supporting Alan's code as the `standard' network kernel code.
The latest revision of the code, NET-3, appears in kernel releases
1.1.5 and later, and is essentially the same code, but with many
fixes, corrections and enhancements.
Alan has added such features as IPX and AX.25 modules. Florian La
Roche, <flla@stud.uni-sb.de> has produced an updated distribution of
network applications.
Unless otherwise stated, this document will refer to the network code
included in the standard kernel releases. On the whole this document
will serve for Fred's code as well, but as the development paths are
now seperate, it is possible that there will be differences between
the two.
2. Disclaimer.
The Linux networking code is a brand new implementation of kernel
based tcp/ip networking. It has been developed from scratch, and is
not a port of any existing kernel networking code.
Because it is a fresh implementation it may still have a number of
bugs or problems with it, and there may be a number of fixes and
patches released. If you are worried about problems then just stick
to the version of network code released with the standard kernel
releases and utility sets. The networking code has a small team of
dedicated people working on it, with a cast of thousands testing the
code, and collecting and reporting bugs and problems. Any problem you
experience is likely to have already been reported, and be being
worked on, and will possible be corrected soon, so be patient, or if
you can help, offer your assistance.
We do not, and cannot, know everything there is to know about the
Linux network software. Please accept and be warned that this document
probably does contain errors. Please read any README files that are
included with any of the various pieces of software described in this
document for more detailed and accurate information. We will attempt
to keep this document as error-free and up-to-date as possible.
Versions of software are current as at time of writing.
NOTE: While its name may appear similar to the Berkeley Software
Distribution NET-2 release, the Linux network code actually has
nothing at all to do with it. Please don't confuse them.
3. Questions already ?
`The only stupid question is the unasked one.'
If you have general configuration questions, and you have been unable
to find the answers after reading the other various HOWTO and FAQ
files, then you would be best served to post them to
comp.os.linux.help, or, if you believe your question to be
specifically related to the Linux Network code, then you could post it
to the NET mailing list. Please include as much relevant information
as possible, there is nothing more annoying than to have a bug or
problem reported without sufficient information to even begin
searching for it.
Version numbers and revisions of code, a detailed account of the
problem, and the circumstances that caused it to occur, are essential.
Trace and debug messages where available should also be considered
mandatory.
If you have a question relating to the configuration of, or problems
experienced with, any linux distribution, regardless of who has
provided it, please contact the prople who created the distribution
first, before attempting to report the problem to the network code
developers. The reason for this is that some of the distributions use
non-standard directory structures, and supply test/non-standard
versions of code and utilities. The developers of the NET-2 code
cannot be expected to offer support for the network code as
distributed in any form, other than as described in this document, or
as per distributed Alpha/Beta test instructions.
To join the Linux NET channel on the mail list server, send mail to:
linux-activists@niksula.hut.fi
with the line:
X-Mn-Admin: join NET
at the top of the message body (not the subject line).
Remember, keep in mind that the NET channel is for development discus-
sions only.
Note also that a PPP list has been established. To join it, use the
same procedure as for joining the NET channel, except specify PPP in
place of NET in the X-Mn-Admin: field.
Note also that a HAMS list has been established. This list has been
established for the discussion of programs related to Amateur Radio.
To join it, follow the same procedure as for joining the NET or PPP
channels, except specify HAMS in place of NET in the X-Mn-Admin:
field.
4. Related Documentation.
If you are looking for information about tcp/ip networking that this
HOWTO does not cover, then you might try the following sources, as
they provide some very useful information.
Olaf Kirch has written a substantial document as part of the Linux
Documentation Project entitled the Linux Network Administration Guide.
This is an excellent document. It covers all aspects of setting up and
using the tcp/ip networking under Linux, including NFS, UUCP, mail,
News, nameserver etc.
Olaf's book supplements this HOWTO, taking up where this document
leaves off. This document covers the installation and configuration of
the NET code, i.e. `How to put your machine on the net'. If you are
new to unix networking, then I strongly urge you to obtain a copy and
read it first. It will answer a lot of questions for you that are not
within the scope of this document.
The current release version is available in:
sunsite.unc.edu
/pub/Linux/docs/linux-doc-project/network-guide/*
There are various versions of the document in this directory. The most
common formats are supported, being plain ascii, Postscript, DVI,
Latex and groff.
The Linux Network Administrators Guide is Copyright (c) by Olaf Kirch.
You should also read the other HOWTO documents relevant to networking
with Linux.
They are:
The Ethernet-HOWTO
(ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/Ethernet-HOWTO) which you
should read if you intend using an ethernet card with Linux. It
includes much more detail on how to select, install and configure an
ethernet card for Linux.
The Serial-HOWTO (http://sunsite.unc.edu/mdw/HOWTO/Serial-HOWTO.html)
if you intend using slip or ppp in server mode.
The Mail-HOWTO (http://sunsite.unc.edu/mdw/HOWTO/Mail-HOWTO.html) and
the News-HOWTO (http://sunsite.unc.edu/mdw/HOWTO/News-HOWTO.html) for
some specific information on setting up Mail and News on your system.
The UUCP-HOWTO (http://sunsite.unc.edu/mdw/HOWTO/UUCP-HOWTO.html) if
you will be connecting to the net via UUCP.
For more general information on Unix network configuration another
good place to look for help on setting up your network is the O'Reilly
and Associates book TCP/IP Network Administration, (the one with the
Crab on the cover). Keep in mind that the Linux Network code is now a
fairly standard implementation of tcp/ip networking, this means that
the commands to configure and use it will work in much the same way as
for those for other unix operating systems. Keep in mind though that
some of the arguments and options might differ slightly from those in
the book.
If you are after some basic tutorial information on tcp/ip networking
generally, then you might take a look at the following documents:
athos.rutgers.edu
/runet/tcp-ip-admin.doc
/runet/tcp-ip-admin.ps
/runet/tcp-ip-intro.doc
/runet/tcp-ip-intro.ps
If you are after some more detailed information on tcp/ip networking
then I highly recommend:
"Internetworking with TCP/IP"
by Douglas E. Comer
ISBN 0-13-474321-0
Prentice Hall publications.
4.1. New versions of this document.
The latest released version of this document can be retrieved by
anonymous ftp from:
sunsite.unc.edu
/pub/Linux/docs/HOWTO/NET-2-HOWTO
/pub/Linux/docs/HOWTO/other-formats/NET-2-HOWTO.{tex,ps,dvi}
via the World Wide Web from the Linux Documentation Project Web Server
(http://sunsite.unc.edu/mdw/linux.html), at page: NET-2-HOWTO
(http://susnite.unc.edu/mdw/HOWTO/NET-2-HOWTO.html) or directly from
me, <terryd@extro.ucc.su.oz.au>. It will also be posted to the
newsgroups: comp.os.linux.announce, comp.os.linux.help, and
news.answers periodically.
You can find news.answers FAQ postings, including this one, archived
on rtfm.mit.edu:/pub/usenet.
4.2. Feedback.
Please send any comments, updates, or suggestions to me,
<terryd@extro.ucc.su.oz.au>. The sooner I get feedback, the sooner I
can update and correct this document. If you find any problems with
it, please mail me instead of posting to one of the newsgroups, as I
may miss it. Thanks.
5. NET-2/NET-3 Supported functionality.
The NET code is a complete kernel based implementation of tcp/ip for
Linux. The NET-2 and NET-3 versions of code support:
Ethernet Cards
Most popular ethernet cards are supported.
SLIP (Serial Line IP) and PPP
for tcp/ip networking over serial lines such as the telephone
via modem, or a local cable between two machines.
Van Jacobsen Header Compression
for compressing the tcp/ip headers to improve slip performance
over low speed lines.
PLIP (Parallel Lines IP)
to allow local connections between two machines using your
printer ports.
NFS (Networked File System)
to allow you to remotely mount another machines filesystems.
AX.25 (A protocol used by Amateur Radio Operators)
Alan Cox has some experimental code available.
PI Card (An 8530 SCC based card used by Amateur Radio Operators)
An experimental PI Card driver is available.
IPX/SPX (Novell)
to allow you to write custom SPX/IPX applications, or to use
Linux as an IPX router.
The NET-2 and NET-3 network code does not yet currently support:
NCP (Novell) support
to allow Linux to serve and mount Novell network devices. This
is being worked on.
Lan types other than ethernet
This means token ring, arcnet, FDDI, etc. An experimental Token
Ring driver is being developed. An experimental ARCNet driver
has also been developed (details further on).
ISDN Support
this is being developed.
5.1. Supported Ethernet cards.
The standard linux kernel release supports the following type of
Ethernet cards:
o NE2000/NE1000 and close compatibles.
o WD80*3 and close compatibles.
o SMC Ultra
o 3c501 (obselete and very slow)
o 3c503 and close compatibles.
o 3c509/3c579
o HP PCLAN (however a newer kernel is required for the HP PCLAN+)
o AT1500 and NE2100 (LANCE and PCnet-ISA) and close compatibles.
o AT1700 (not clones)
o DEPCA and close compatibles.
o D-Link DE600 pocket adaptor and close compatibles.
o AT-LAN-TEC/RealTek pocket adaptor and close compatibles.
Additional drivers are available in the 1.1.* and later development
kernels.
The Ethernet-HOWTO contains a lot of very useful information on the
supported ethernet cards, including information on how to choose an
ethernet card if you are intending to puchase some specifically for
Linux.
As mentioned above, Linux supports other means of network connection
if you don't have access to an ethernet card or connection. Many
universities and businesses worldwide offer some form of dial-up
network access. Generally these forms of access will offer an option
of either SLIP or PPP access, so you will be well catered for. All you
will need is a telephone modem, the one you already have may well be
good enough, and to configure your Linux system appropriately. There
are sections below that describe exactly what you need.
6. Getting the NET-2/NET-3 software.
Before you can configure the networking software you must obtain all
of the bits and pieces that make it up. These include the current
version of the kernel code (version 1.0 or later), the correct system
libraries, the tcp/ip configuration programs and files (e.g.
/sbin/ifconfig, /etc/hosts etc.), and finally a set of network
application programs (such as telnet, ftp, rlogin etc.).
If you obtained Linux from a distribution you may already have all
that you need. Check and make sure that you do. For example, some
Linux distributions come with all of the network configuration files,
binaries, libraries, and kernel installed, so there's no reason to get
the following files.
NOTE: they may be in directories and files different to those
specified in this HOWTO document
If you DO have the network software, skip to the `Configuring the
kernel' section. If you DO NOT have the network software follow the
following directions.
6.1. The kernel source.
Version 1.0 of the Linux kernel is the production version. Any of the
Linux kernels after that release are enhancements or bug fixes. If you
feel at all concerned about the possibility of having to patch and
modify the kernel source, then you should stick to this release, as it
will do most of what you want it to. In the case of the networking
code though, I strongly suggest you just take a deep breath and follow
the newer releases of code, as there have been many changes in the
newer version kernels that affect networking. I know you hear it from
everyone and everywhere, but when trying out any new version of kernel
software you should always ensure that you have sufficient backups of
your system just in case something goes seriously wrong while you are
testing.
The current kernel version is found in:
ftp.funet.fi
/pub/OS/Linux/PEOPLE/Linus/v1.1/v1.1.45.tar.gz
This is a gzipped file, so you will need gzip to uncompress it.
To install it, try:
# cd /usr/src
# mv linux linux.old
# gzip -dc v.1.1.45.tar.gz | tar xvf -
You may also find some files called patch46.gz ... in the same
directory. These are patch files. If you have a linux kernel that is
version 1.1.45 then what this means is that you have linux kernel
version 1.1.0 with patches 1 to 45 applied, so you won't need to apply
any of these. If there are any patch files that are greater than the
version of kernel you have, you should obtain all of those above, and
apply them, in sequence, with something like the following commands:
# cd /usr/src
# gzip -dc .../patch1.gz | patch -p0
# gzip -dc .../patch2.gz | patch -p0
# gzip -dc .../patch3.gz | patch -p0
...
6.2. The libraries.
You'll want at least version 4.4.2 of libc, as there were problems
with earlier version that affected subnet masks.
The current libraries (libc-4.5.26) can be found in:
sunsite.unc.edu
/pub/Linux/GCC/
You will need at least the following files:
o image-4.5.26.tar.gz
o inc-4.5.26.tar.gz
o extra-4.5.26.tar.gz
o release.libc-4.5.26
You MUST read release.libc-4.5.26 before you install the libraries.
Please note the single line in the release document regarding deleting
the older version of /usr/lib/libgcc.* or else your compiles will not
link properly. Please note that to use release 4.5.26 you will also
need at least GCC version 2.5.7, and Linux kernel 1.0 or later.
6.3. The network configuration tool suite.
You will need the utility suite that provides tools to configure your
network support.
The current NET-2 utility suite is available from:
sunacm.swan.ac.uk
/pub/misc/Linux/Networking/PROGRAMS/NetTools/net-tools-1.1.38.tar.gz
Because the kernel networking code is still changing some changes to
the network tools have been necessary as new kernels are released, so
you will need to choose the version that is appropiate for the kernel
version you intend to use.
The filenames reflect the earliest version of kernel that the tools
will work with. Please choose the filename whose version equals, or is
less than the version of kernel source you intend to use.
To build and install the tools, you should try:
# cd /usr/src
# mkdir net-tools
# cd net-tools
# gzip -dc net-tools-1.1.38.tar.gz | tar xvf -
# make config
# make
If everything makes ok, then:
# make install
If you use a kernel version 1.1.26 or earlier you should look in:
sunacm.swan.ac.uk
/pub/misc/Linux/Networking/PROGRAMS/Other/net032/
In this directory you will find three versions of the network tools.
The following table lists net-032 package name with the relevant
kernel versions:
net-0.32d-net3.tar.gz 1.1.12+
net-0.32b.tar.gz 1.1.4+
net-0.32.old.tar.gz pre 1.1.4 kernels
These packages include the essential network configuration programs
such as ifconfig, route, netstat etc. These will be discussed later.
6.4. The network applications.
You will want a number of network application programs. These are
programs like telnet, ftp, finger and their daemons at least. Florian
La Roche, <flla@stud.uni-sb.de> has put together a fairly complete
distribution of network applications in both binary and source form.
The tcp/ip application binaries and some sample config files are found
in:
ftp.funet.fi
/pub/OS/Linux/PEOPLE/Linus/net-source/NetKit/NetKit-A-0.07.bin.tar.gz
/pub/OS/Linux/PEOPLE/Linus/net-source/NetKit/NetKit-B-0.06.bin.tar.gz
If there are newer versions then use the newer versions. Please read
the README file first just to make sure that you have the necessary
prerequisites.
Be sure to make backups of any config files important to you. If this
is a new installation you probably don't have any. You can unpack each
of the packages above with the command:
# cd /
# gzip -dc filename.tar.z | tar xpvlf -
IMPORTANT NOTE: Florian has built and prepackaged these tar files for
your convenience. Florian has attempted to make them as complete as
possible and has included a distribution of the binaries found in the
net-tools-n.n.nn releases. Unfortunately Florian has chosen not to use
the same directory structure as Alan did when he prepared the
installation script for the net-tools. This will mean that you should
be very careful when installing them. Florian will change this later
so that this difference is not a problem, but until then, I suggest
you do the following instead of the above:
- Unpack the binaries somewhere safe:
# cd /usr/src
# mkdir NetKit
# cd NetKit
# gzip -dc NetKit-A-0.07.bin.tar.gz | tar xpvlf -
# gzip -dc NetKit-B-0.06.bin.tar.gz | tar xpvlf -
- Remove Florians copies of the network tools previously described:
# rm ./bin/hostname ./sbin/route ./sbin/ifconfig ./sbin/netstat
# rm ./usr/sbin/arp ./usr/sbin/rarp ./usr/sbin/slattach
- Copy Florian's files into their new home:
# cp -vrpd . /
6.5. Additional drivers or packages.
If you want to add some developmental, or Alpha/Beta test code, such
as AX.25 support, you will need to obtain the appropriate support
software for those packages. Please check the relevant sections for
those packages in this document for more detail.
7. Configuring the kernel.
Before you can use any of the network tools, or configure any network
devices, you must ensure that your kernel has the necessary network
support built into it. The best way of doing this is to compile your
own, selecting which options you want and which you don't.
Assuming you have obtained and untarred the kernel source already, and
applied any patches that you might need to have applied to get any
nonstandard or developmental software installed, all you have to do is
edit /usr/src/linux/drivers/net/CONFIG. This file has many comments to
guide you in editing it,and in general you will need to edit very
little, as it has sensible defaults. In my case I don't need to edit
it at all. This file is really necesary if your ethernet card is an
unusual one, or is one that isn't automatically detected by the
ethernet driver. It allows you to hard code some of the elements of
your ethernet hardware. For example, if your ethernet card is a close,
but not exact clone of a WD-8013, then you might have to configure the
shared memory address to ensure the driver detects and drives the card
properly. Please check the Ethernet-HOWTO for more definitive
information on this file and its effect on ethernet cards. This file
also contains configurable parameters for PLIP, though the defaults
should again be ok unless you have a particularly slow machine.
When you are happy that the CONFIG file is suitable for your purposes,
then you can proceed to build the kernel. Your first step will be to
edit the top level Makefile to ensure the kernel will be built with
the appropriate VGA settings, and then you must run the kernel
configuration program:
# cd /usr/src/linux
# make config
You will be asked a series of questions. There are four sections
relevant to the networking code. They are the General setup,
Networking options, Network device support, and the Filesystems
sections. The most difficult to configure is the Network device
support section, as it is where you select what types of physical
devices you want configured. On the whole you can just use the default
values for the other sections fairly safely. The following will give
you an idea of how to proceed:
*
* General setup
*
...
...
Networking support (CONFIG_NET) [y] y
...
...
In the General setup section you simply select whether you want
network support or not. Naturally you must answer yes.
*
* Networking options
*
TCP/IP networking (CONFIG_INET) [y] y
IP forwarding/gatewaying (CONFIG_IP_FORWARD) [y] y
*
* (it is safe to leave these untouched)
*
PC/TCP compatibility mode (CONFIG_INET_PCTCP) [n] n
Reverse ARP (CONFIG_INET_RARP) [n] n
Assume subnets are local (CONFIG_INET_SNARL) [y] y
Disable NAGLE algorithm (normally enabled) (CONFIG_TCP_NAGLE_OFF) [n] n
The IPX protocol (CONFIG_IPX) [n] n
The second half of the Networking options section allows you to enable
or disable some funky features that you can safely accept the defaults
on until you have some idea why you want to change them.
*
* Network device support
*
Network device support? (CONFIG_NETDEVICES) [y]
Dummy net driver support (CONFIG_DUMMY) [n]
SLIP (serial line) support (CONFIG_SLIP) [y] y
CSLIP compressed headers (SL_COMPRESSED) [y] y
PPP (point-to-point) support (CONFIG_PPP) [y] y
Load balancing support (experimental) (CONFIG_SLAVE_BALANCING) [n] n
Do you want to be offered ALPHA test drivers (CONFIG_NET_ALPHA) [n] n
Western Digital/SMC cards (CONFIG_NET_VENDOR_SMC) [y] y
WD80*3 support (CONFIG_WD80x3) [y] y
SMC Ultra support (CONFIG_ULTRA) [n] n
3COM cards (CONFIG_NET_VENDOR_3COM) [n] n
Other ISA cards (CONFIG_NET_ISA) [n] n
PLIP (parallel port) support (CONFIG_PLIP) [n] n
EISA and on board controllers (CONFIG_NET_EISA) [n] n
Apricot Xen-II on board ethernet (CONFIG_APRICOT) [n] n
Pocket and portable adaptors (CONFIG_NET_POCKET) [n] n
*
This section is the most important, and the most involved. It is where
you select what hardware devices you want to support. You can see that
I have selected SLIP support with header compression, PPP, the WD80*3
driver, and nothing else. Simply answer `y' to whatever you want to
play with, and `n' to that you don't.
*
* Filesystems
*
...
...
/proc filesystem support (CONFIG_PROC_FS) [y]
NFS filesystem support (CONFIG_NFS_FS) [y]
...
...
If you wish to run an NFS client then you will want to include the NFS
filesystem type. You will need to include the /proc filesystem because
a number of the network utilities use it.
After you have completed the configuration, all that remains is to
actually compile the kernel:
# make dep
# make
Don't forget to make zlilo if the new kernel compiles and tests ok.
8. Configuring the Network Devices.
If everything has gone ok so far, then you will have a Linux kernel
which supports the network devices you intend to use, and you also
have the network tools with which to configure them. Now comes the fun
part! You'll need to configure each of the devices you intend to use.
This configuration generally amounts to telling each device things
like what its IP address will be, and what network it is connected to.
In past versions of this document I have presented near complete
versions of the various configuration files and included comments to
modify or delete lines from them as appropriate. From this version
onwards I will take a slightly different approach which I hope will
result in you having a complete set of uncluttered configuration files
that you have built from scratch so you know exactly what is in them,
and why. I'll describe each of these files, and their function, as we
come to them.
8.1. Configuring the special device files in /dev
You do not need to configure any special device files in the /dev
directory for Linux Networking. Linux does not need or use them as
other operating systems might. The devices are built dynamically in
memory by the kernel, and since they are only names there is no need
for them to have an appearance directly to you. The kernel provides
all of the programming hooks and interfaces that you need to utilise
them effectively.
8.2. What information do I need before I begin ?
Before you can configure the networking software, you will need to
know a number of pieces of information about your network connection.
Your network provider or administrator will be able to provide you
with most of them.
8.2.1. IP Address.
This is the unique machine address, in dotted decimal notation, that
your machine will use. An example is 128.253.153.54. Your network
administrator will provide you with this information.
If you will be using a slip or plip connection you may not need this
information, so skip it until we get to the slip device.
If you're using the loopback device only, ie no ethernet, slip or plip
support, then you won't need an ip address as the loopback port always
uses the address 127.0.0.1.
8.2.2. Network Mask (`netmask').
For performance reasons it is desirable to limit the number of hosts
on any particular segment of a network. For this reason it is common
for network administrators to divide their network into a number of
smaller networks, known as subnets, which each have a portion of the
network addresses assigned to them. The network mask is a pattern of
bits, which when overlayed onto an address on your network, will tell
you which subnetwork it belongs to. This is very important for
routing, and if you find for example, that you can happily talk to
people outside your network, but not to some people on your own
network, then it is quite likely that you have specified an incorrect
subnet mask.
Your network adminstrators will have chosen the netmask when the
network was designed, and therefore they should be able to supply you
with the correct mask to use. Most networks are class-C subnetworks
which use 255.255.255.0 as their netmask. Other larger networks use
class-B netmasks (255.255.0.0). The NET-2/NET-3 code will
automatically select a default mask when you assign an address to a
device. The default assumes that your network has not been subnetted.
The NET-2/NET-3 code will choose the following masks by default:
For addresses with the first byte:
1-127 255.0.0.0 (Class A)
128-191 255.255.0.0 (Class B)
192+ 255.255.255.0 (Class C)
if one of these doesn't work for you, try another. If this doesn't
work ask your network administrator or local network guru (dime a
dozen) for help.
You don't need to worry about a netmask for the loopback port, or if
you are running slip/plip.
8.2.3. Network Address.
This is your IP address masked (bitwise AND) with your netmask. For
example:
If your netmask is: 255.255.255.0
and your IP address is: 128.253.154.32 &&
---------------
your Network address is: 128.253.154.0 =
8.2.4. Broadcast Address.
`A shout is a whisper that everyone hears whether they need to or not'
This is normally your network address logically ORed with your netmask
inverted. This is simpler than it sounds. For a Class-C network, with
network mask 255.255.255.0, your Broadcast Address will be your
network address (calculated above), logically ORed with 0.0.0.255, the
network mask inverted.
A worked example might look like:
If your netmask is: 255.255.255.0 !
the netmask inverted is: 0. 0. 0.255 =
If your Network address is: 128.253.154.0 ||
----------------
Your broadcast address is: 128.253.154.255 =
Note that for historical reasons some networks use the network address
as the broadcast address. If you have any doubts contact your network
administrator.
If you have access to a sniffer, or some other device capable of
providing you with a trace of your network traffic, then you might be
able to determine both the network and broadcast addresses by watching
other traffic on the lan. Keep an eye open for, (or filter everything
except), ethernet frames destined for the ethernet broadcast address:
ff:ff:ff:ff:ff:ff. If any of them has an IP source address of your
local router, and the protocol ID is not ARP, then check the
destination IP address, because this datagram may well be a RIP
routing broadcast from your router, in which case the destination IP
address will be your broadcast address.
Once again, if you're not sure, check with your network administrator,
they'd rather help you, than have you connect your machine
misconfigured.
8.2.5. Router (`Gateway') Address.
`There must be some way out of here.'
This is the address of the machine that connects your network to the
rest of the Internet. It is your `gateway' to the outside world. A
couple of conventions exist for allocating addresses to routers which
your network might follow, they are: The router is the lowest numbered
address on the network, the router is the highest numbered host on the
network. Probably the most common is the first, where the router will
have an address that is mostly the same as your own, except with a .1
as the last byte. eg. if your address is 128.253.154.32, then your
router might be 128.253.154.1. The router can in fact have any address
valid on your network and function properly, the address doesn't
matter at all. There may in fact even be more than one router on your
network. You will probably need to talk to your network adminstrator
to properly identify your router address.
If you're using only loopback then you don't need a router address. If
you're using PPP then you also don't need your router address, because
PPP will automatically determine the correct address for you. If
you're using SLIP, then your router address will be your SLIP server
address.
8.2.6. Nameserver Address.
Most machines on the net have access to a name server which translates
human tolerable hostnames into machine tolerable addresses, and vice
versa. Your network administrators will again tell you the address of
your nearest nameserver. You can in fact run a nameserver on your own
machine by running named, in which case your nameserver address will
be 127.0.0.1, the loopback port address. However it is not required
that you run named at all; see section `named' for more information.
If you're only using loopback then you don't need to know the
nameserver address since you're only going to be talking to your own
machine.
8.2.7. NOTE for SLIP/PLIP/PPP users.
You may or may not in fact need to know any of the above information.
Whether you do or not will depend on exactly how your network
connection is achieved, and the capabilities of the machine at the
other end of the link. You'll find more detail in the section relevant
to configuration of the SLIP/PLIP and PPP devices.
8.3. /etc/rc.d/rc.inet1,2 or /etc/rc.net
While the commands to configure your network devices can be typed
manually each time, you will probably want to record them somewhere so
that your network is configured automatically when you boot your
machine.
The `rc' files are specifically designed for this purpose. For the
non-unix-wizard: `rc' file are run at bootup time by the init program
and start up all of the basic system programs such as syslog, update,
and cron. They are analagous to the MS-DOS autoexec.bat file, and rc
might stand for `runtime commands'. By convention these files are kept
under the /etc directory. The Linux Filesystem Standard doesn't go so
far as to describe exactly where your rc files should go, stating that
it is ok for them to follow either the BSD (/etc/rc.*) or System-V
(/etc/rc.d/rc*) conventions. Alan, Fred and I all use the System-V
convention, so that is what you will see described here. This means
that these files are found in /etc/rc.d and are called rc.inet1 and
rc.inet2. The first rc file that gets called at bootup time is
/etc/rc, and it in turn calls others, such as rc.inet1, which in turn
might called rc.inet2. It doesn't really matter where they are kept,
or what they are called, so long as init can find them.
In some distributions the rc file for the network is called rc.net and
is in the /etc subdirectory. The rc.net file on these systems is
simply the rc.inet1 and the rc.inet2 files combined into one file that
gets executed. It doesn't matter where the commands appear, so long as
you configure the interfaces before starting the network daemons and
applications.
I will refer to these files as rc.inet1 and rc.inet2, and I keep them
in the /etc/rc.d, so if you are using one of the distributions that
uses rc.net, or you want to keep the files somewhere else, then you
will have to make appropriate adjustments as you go.
We will be building these files from scratch as we go.
8.3.1. rc.inet1
The rc.inet1 file configures the basic tcp/ip interaces for your
machine using two programs: /sbin/ifconfig, and /sbin/route.
8.3.1.1. ifconfig
/sbin/ifconfig is used for configuring your interfaces with the
parameters that they require to function, such as their IP address,
network mask, broadcast addresses and similar. You can use the
ifconfig command with no parameters to display the configuration of
all network devices. Please check the ifconfig man page for more
detail on its use.
8.3.1.2. route
/sbin/route is used to create, modify, and delete entries in a table
(the routing table) that the networking code will look at when it has
a datagram that it needs to transmit. The routing table lists
destination address, and the interface that that address is reachable
via. You can use the route command with no parameters to display the
contents of the routing table. Please check the route man page for
more detail on its use.
8.3.2. rc.inet2
The rc.inet2 file starts any network daemons such as inetd, portmapper
and so on. This will be covered in more detail in section `rc.inet2',
so for the moment we will concentrate on rc.inet1. I have mentioned
this file here so that if you have some other configuration, such as a
single rc.net file you will understand what the second half of it
represents. it is important to remember that you must start your
network applications and daemons after you have configured your
network devices.
8.4. Configuring the Loopback device (mandatory).
The loopback device isn't really a hardware device. It is a software
construct that looks like a physical interface. Its function is to
happily allow you to connect to yourself, and to test network software
without actually having to be connected to a network of any kind. This
is great if you are developing network software and you have a slip
connection. You can write and test the code locally, and then when
you are ready to test it on a live network, eatablish your slip
connection and test it out. You won't hurt others users if your
program misbehaves.
By convention, the loopback device always has an IP address of
127.0.0.1 and so you will use this address when configuring it.
The loopback device for Linux is called `lo'. You will now make the
first entry into your rc.inet1 file. The following code fragment will
work for you:
#!/bin/sh
#
# rc.inet1 -- configures network devices.
#
# Attach the loopback device.
/sbin/ifconfig lo 127.0.0.1
#
# Add a route to point to the loopback device.
/sbin/route add 127.0.0.1
# End loopback
#
You have used the ifconfig program to give the loopback interface its
IP address, and route program to create an entry in the routing table
that will ensure that all datagrams destined for 127.0.0.1 will be
sent to the loopback port.
There are two important points to note here.
Firstly, the netmask and broadcast addresses have been allowed to take
the default values for the loopback device described earlier in
section `Network Mask'. To see what they are, try the ifconfig program
without any arguments.
# ifconfig
lo Link encap Local Loopback
inet addr 127.0.0.1 Bcast 127.255.255.255 Mask 255.0.0.0
UP BROADCAST LOOPBACK RUNNING MTU 2000 Metric 1
RX packets 0 errors 0 dropped 0 overrun 0
TX packets 30 errors 0 dropped 0 overrun 0
#
Secondly, its not obvious how the route command chose the loopback
device as the device for the route to 127.0.0.1. The route program is
smart enough to know that 127.0.0.1 belongs to the network supported
by the loopback device. It works this out by checking the IP address
and the netmask. You can use the route command with no arguments to
display the contents of the routing table:
# route
Kernel routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
127.0.0.0 * 255.0.0.0 U 0 0 30 lo
#
Note: You might want to use the -n argument if your name resolver is
not yet configured properly. The -n argument tells route to just
display the numeric addresses, and to not bother looking up the name.
8.5. Configuring an ethernet device. (optional)
You'll only be interested in this section if you wish to configure an
ethernet card, if not then skip on ahead to the next section.
To configure an ethernet card is only slightly more complicated than
configuring the loopback device. This time you should probably specify
explicitly the network mask and the broadcast address, unless you are
sure that the defaults will work ok, and they probably will.
For this you will need the IP address that you have been assigned, the
network mask in use on your network, and the broadcast address in use.
The first ethernet device for a Linux system is called `eth0', the
second `eth1' and so forth. You will now add a section to your
rc.inet1 file. The following code fragment will work for you if you
change the addresses specified for real ones:
#
# Attach an ethernet device
#
# configure the IP address, netmask and broadcast address.
/sbin/ifconfig eth0 IPA.IPA.IPA.IPA
/sbin/ifconfig eth0 netmask NMK.NMK.NMK.NMK
/sbin/ifconfig eth0 broadcast BCA.BCA.BCA.BCA
#
# add a network route to point to it:
/sbin/route add -net NWA.NWA.NWA.NWA device eth0
#
# End ethernet
#
Where:
IPA.IPA.IPA.IPA
represents your IP Address.
NMK.NMK.NMK.NMK
represents your netmask.
BCA.BCA.BCA.BCA
represents your Broadcast address.
NWA.NWA.NWA.NWA
represents your Network Address.
Note the use of the -net argument to the route command. This tells
route that the route to be added is a route to a network, and not to a
host. There is an alternative method of achieving this, you can leave
off the -net if you have the network address listed in the
/etc/networks file. This is covered later in section `/etc/networks'.
8.6. Configuring a SLIP device (optional)
SLIP (Serial Line Internet Protocol) allows you to use tcp/ip over a
serial line, be that a phone line with a dialup modem, or a leased
line of some sort. Of course to use slip you need access to a slip-
server in your area. Many universities and businesses provide slip
access all over the world.
Slip uses the serial ports on your machine to carry IP datagrams. To
do this it must take control of the serial device. Slip device names
are named sl0, sl1 etc. How do these correspond to your serial devices
? The networking code uses what is called an ioctl (i/o control) call
to change the serial devices into slip devices. There are two programs
supplied that can do this, they are called dip and slattach
8.6.1. dip
dip (Dialup IP) is a smart program that is able to set the speed of
the serial device, command your modem to dial the remote end of the
link, automatically log you into the remote server, search for
messages sent to you by the server, and extract information for them
such as your IP address, and perform the ioctl necessary to switch
your serial port into slip mode. dip has a powerful scripting ability,
and it is this that you can exploit to automate your logon procedure.
dip comes supplied in the net-032/net-tools package. There have been
a number of other versions of dip produced which offer a variety of
new features. You will find them at:
sunsite.unc.edu
/pub/Linux/system/Network/serial/dip*
The dip-uri version seems to be the more popular, but I suggest you
take a close look at each to determine which offers enhancements that
you find useful.
8.6.2. slattach
slattach on the other hand is a very simple program, that is very easy
to use, but does not have the sophistication of dip. slattach is
ideal to use where you have a permanent connection to your server,
such as a physical cable, or a leased line.
8.6.3. When do I use which ?
You would use dip when your link to the machine that is your slip
server is a dialup modem, or some other termporary link. You would use
slattach when you have a leased line, perhaps a cable, between your
machine and the server, and there is no special action needed to get
the link working. See section `Permanent Slip connection' for more
information.
Configuring slip is much like configuring an Ethernet interface (read
section `Configuring an ethernet device' above). However there are a
few key differences.
First of all, slip links are unlink ethernet networks in that there is
only ever two hosts on the network, one at each end of the link.
Unlike an ethernet that is available for use as soon are you are
cabled, with slip, depending on the type of link you have, you may
have to initialise your network connection in some special way.
If you are using dip then this would not normally be done at boot
time, but at some time later, when you were ready to use the link. It
is possible to automate this procedure. If you are using slattach then
you will probably want to add a section to your rc.inet1 file. This
will be described soon.
There are two major types of slip servers: Dynamic IP address servers
and static IP address servers. Almost every slip server will prompt
you to login using a username and password when dialing in. dip can
handle logging you in automatically.
8.6.4. Static slip server with a dialup line and DIP.
A static slip server in one in which you have been supplied an IP
address that is exclusively yours. Each time you connect to the
server, you will configure your slip port with that address. The
static slip server will answer your modem call, possibly prompt you
for a username and password, and then route any datagrams destined for
your address to you via that connection. If you have a static server,
then you may want to put entries for your hostname and IP address
(since you know what it will be) into your /etc/hosts. You should also
configure some other files such as: rc.inet2, host.conf, resolv.conf,
/etc/HOSTNAME, and rc.local. Remember that when configuring rc.inet1,
you don't need to add any special commands for your slip connection
since it is dip that does all of the hard work for you in configuring
your interface. You will need to give dip the appropriate information,
and it will configure the interface for you after commanding the modem
to establish the call, and logging you into your slip server.
If this is how your slip server works then you can move to section
`Using Dip' to learn how to configure dip appropriately.
8.6.5. Dynamic slip server with a dialup line and DIP.
A dynamic slip server is one which allocates you an IP address
randomly, from a pool of addresses, each time you logon. This means
that there is no guarantee that you will have any particular address
each time, and that address may well be used by someone else after you
have logged off. The netework administrator who configured the slip
server will have assigned a pool of address for the slip server to
use, when the server receives a new incoming call, it finds the first
unused address, guides the caller through the login process, and then
prints a welcome message that contains the IP address it has
allocated, and will proceed to use that IP address for the duration of
that call.
Configuring for this type of server is similar to configuring for a
static server, except that you must add a step where you obtain the IP
address that the server has allocated for you and configure your slip
device with that.
Again, dip does the hard work, and new versions are smart enough to
not only log you in, but to also be able to automatically read the IP
address printed in the welcome message, and store it so that you can
have it configure your slip device with it.
If this is how your slip server works then you can move to section
`Using Dip' to learn how to configure dip appropriately.
8.6.6. Using DIP.
As explained earlier, dip is a powerful program that can simplify and
automate the process of dialling into the slip server, logging you in,
starting the connection, and configuring your slip devices with the
appropriate ifconfig and route commands.
Essentially to use dip you'll write a `chat script', which is
basically a list of commands that dip understands that tell dip how to
perform each of the actions you want it to perform. See sample.dip in
the net-032 package for an explanation. dip is quite a powerful
program, with many options. Instead of going into all of them here you
should looks at the man page, README and sample files from tsx-11, and
the net-032 distribution.
You may notice that the sample.dip script assumes that you're using a
static slip server, so you know what your IP address is beforehand.
For dynamic slip servers, the newer versions of dip include a command
you can use to automatically read and configure your slip device with
the IP address that the dynamic server allocates for you. The
following sample was supplied by Paul Mossip, and is probably a good
starting point for you. You might like to save it as /etc/dipscript:
#
# Connection script for SLIP to knoware.nl.mugnet.org
#
# Fetch the IP address of our target host.
main:
# Set the desired serial port and speed.
port /dev/cua0
speed 38400
# Reset the modem and terminal line.
reset
# Prepare for dialing.
send ATZ1\r
wait OK 4
if $errlvl != 0 goto error
dial 666-0999 ## Change to your server's number!
if $errlvl != 0 goto error
wait CONNECT 60
if $errlvl != 0 goto error
# We are connected. Login to the system.
login:
sleep 3
send \r\n\r\n
wait gracelands> 20 ## Change to your server's prompt
if $errlvl != 0 goto error
send login\n
wait name: 10 ## Wait username: prompt
if $errlvl != 0 goto erro
send elvisp\n ## Change to your own!
wait ord: 10 ## Wait password prompt
if $errlvl != 0 goto error
send alive\n ## Change to your own!
wait gracelands> 10
if $errlvl != 0 goto error
send slip\n ## Change to suit your server
wait SLIP 30 ## Wait for SLIP prompt
if $errlvl != 0 goto error
get $local remote 10 ## Assumes the server sends your IP..
if $errlvl != 0 goto error ## address as soon as you enter slip.
get $remote gracelands ## slip server address from /etc/hosts
done:
print CONNECTED to $remote with address $rmtip we are $local
default
mode SLIP
goto exit
error:
print SLIP to $host failed.
exit:
#
# End dip script
---End of part 1/3---
next reply other threads:[~1994-11-18 17:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-18 17:11 Terry Dawson [this message]
1994-11-18 17:11 ` Linux NET-2 HOWTO (part 2/3) Terry Dawson
1994-11-18 17:13 ` Linux NET-2 HOWTO (part 3/3) Terry Dawson
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox