10. Setting Up a Linux-Based LAN
This chapter explains how to set up a local-area network (LAN) that
includes a Linux Samba server, which lets Microsoft Windows and UNIX
systems access shared files and printers hosted by your Linux system. The
chapter explains how to administer a simple LAN and describes how to
install, configure, and administer Samba servers and clients. Integrating your
Linux system with an existing LAN is no more complicated than setting up
your own LAN; the chapter also explains how to connect to an existing
network. The chapter also explains how to use Linux backup and recovery
utilities so that client systems can create and use backups stored on the
server.
10.1 Introduction
One of the great strengths of Linux is its powerful and robust networking
capabilities. The good news is that everything about Linux's networking
setup is open to inspection and completely configurable. Nothing is hidden
from the user, and no parameters are forced on you. The challenge is to get
the most out of this setup for your needs.
Basic networking principles don't differ much between Windows and Linux,
and indeed the principles aren't unfamiliar. This chapter starts with an
overview of networking, and then looks in more detail at Linux networking
on a Local Area Network (LAN). In the next two chapters, you'll learn about
making a dialup Internet connection, and setting up Wide Area Network
(WAN) services.
Most computers today handle network traffic much as the post office
handles mail. Think, for example, of the steps involved in sending and
receiving a letter. Your postal carrier must know where to drop off and
where to pick up mail. So your home must have some kind of recognizable
interface; we call this a mailbox. And whereas your postal carrier may know
your neighborhood quite well, delivery in other areas will require other
carriers. Mail is passed to these other carriers through a gateway; we call this
the Post Office. Although you can think of the whole postal system as one
comes with tools to help you automate network configuration. In this chapter
you'll look at networking on a LAN, and we'll start by looking at how to set
up LAN networking.
10.2 Network Administration
The Debian GNU/Linux install program lets you specify a network
configuration that's used when your system is first booted. If your network
configuration changes, you can re-install Linux. However, you can spare
yourself much inconvenience by learning how Linux stores its network
configuration. As you'll see, by using a text editor to revise some files, you
can alter your system's network configuration without going through the
pain of re-installing Linux.
10.2.1 Network Hardware Configuration
If you replace your network adapter card with a different model card, you
must run the modconf program, which lets you specify the driver that
operates your card. To do so, simply login as root and type the command:
modconf
You're already familiar with the modconf program. It's the same program
you used to specify drivers when you originally installed Linux. If you have
difficulty using modconf, refer to the section titled Section 3.1.2.13,
"Configuring device driver modules" in Chapter 3, Installing Linux.
You must reboot your system before changes made by modconf take
effect.
10.2.2 Basic Host Information
When you installed Linux, you specified a hostname for your system. If you
want to change the hostname associated with your system, you can edit the
file /etc/hostname by using ae or another editor of your choosing. Because
the file - like most configuration files - has restrictive permissions, you must
login as root in order to modify it.
The format of the /etc/hostname file is simple. The file contains a single line,
which contains the hostname of your system; for example, debian. If you
forwarding data packets from Internet hosts to your system.
NOTE: If your system connects to the Internet via PPP, the PPP system
establishes a network configuation dynamically. You'll learn how this works
in the next chapter.
The information that describes your local area network is contained in the
file /etc/init.d/network, which you can easily edit. Here's a typical
/etc/init.d/network file:
#! /bin/sh
inconfig lo 127.0.0.1
route add -net 127.0.0.0
IPADDR=192.168.1.10
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.1
ifconfig eth0 ${IPADDR} netmask ${NETMASK}
broadcast ${BROADCAST}
route add default qw ${GATEWAY} metric 1
The lines you're concerned with are the lines four through eight, each of
which has the following form:
variable=
ipnumber
The lines associate a name, given by variable, with a network address,
given by ipnumber. The variables are referenced by the following three
lines, which are commands that configure networking.
To change your network configuration, you need merely to associate the
proper IP number with each variable. You can do so by logging in as root
and modifying the /etc/init.d/network file by using a text editor. Table 10.1
describes each variable. Your network administrator should be able to
provide you with the proper values.
it's unlikely that an NIS server is available. Therefore, most systems can
query a DNS server and, failing to obtain an answer, read the /etc/hosts file.
Alternatively, most systems can read the etc/hosts file and, failing to obtain
an answer, query a DNS server. The second alternative is generally better,
because reading the /etc/hosts file takes less time than querying a DNS
server.
The /etc/host.conf/ file specifies which of these three operations are
performed, and the order in which they're attempted. You can edit this file
by logging in as root. Here's a typical file:
order hosts,bind
multi on
The order line specifies that the system should first consult the /etc/hosts
file and then query a DNS server, referred to as bind because of the
Berkeley Internet Name Daemon, an early DNS server.
The multi line specifies that your system will attempt to locate all possible
names for a host when it reads the /etc/hosts file. Unless that file is very
large (hundreds or thousands of lines), you should include the multi line.
10.2.6 Miscellaneous Network Configuration Options
The hosts file, /etc/hosts, lets your system determine the network address
number that corresponds to a hostname, without querying a DNS server.
Besides being faster than querying a DNS server, the /etc/hosts file is always
available.
Entries in the file have two parts:
an IP address
a hostname, or a list of hostnames separated by spaces
By default, the hosts file contains an entry that associates the hostname
localhost with the IP address 127.0.0.1. It's not necessary that you include
any other entries in the /etc/hosts file. However, most system administrators
include at least a second line, which associates the local hostname with its
network address. Here's a typical file:
Linux systems provide support for SMB via a package known as Samba.
Like SMB, Samba lets you:
Share printers and files among Microsoft Windows, OS/2, Netware,
and Unix systems
Establish a simple nameserver for identifying systems on your local
area network
Backup PC files to a Linux system and restore them
Administer users and passwords
Samba has proven its reliability and high performance in many
organizations. According to the online survey at
Bank of America is
using Samba in a configuration that includes about 15,000 clients, and
Hewlett-Packard is using Samba in a configuration that includes about 7,000
clients.
10.3.1 Samba Server Installation
If you've never installed and configured a network server, Samba's a good
place to begin; its installation and configuration are generally simple and
straightforward.
Samba includes the smbd program, which runs as a daemon, several utility
programs, man pages and other documentation, and the configuration file:
/etc/smb.conf. You'll learn how to configure the /etc/smb.conf file in the next
subsection.
NOTE: The pending unstable version of Samba places its configuration files
in /etc/samba, rather than /etc. If you install a recent version of Samba, you
should look in /etc/samba for the Samba configuration files.
10.3.2 Configuring Samba
The /etc/smb.conf file lets you specify a variety of options that control
Samba's operation. The install script for Samba establishes a simple
/etc/sbm.conf that may meet your requirements.
You can edit the /etc/sbm.conf file to suit your special needs by using your
group
Option Description
Base workgroup The workgroup name displayed when the server is
Table 10.2: Samba Global Variables
Option
group
Option Description
queried by a client.
netbios
name
The name by which the server is known to the
NetBIOS nameserver.
server
string
The text string displayed to describe the server.
Base
(cont.)
interfaces The IP address of the interface or the IP addresses of
the interfaces through which Samba should listen.
Each IP address is followed by a forward slash and a
number that specifies the number of bits that pertain
to the network portion of the IP address (usually
24). If this option is not set, Samba attempts to
locate and automatically configure a primary
interface.