Tải bản đầy đủ (.pdf) (31 trang)

Networks- The Connection

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (380.56 KB, 31 trang )

Systems Administration Chapter 16: Networks: The Connection
Page 375
Chapter
Networks: The Connection

Introduction
Connecting computers to networks and managing those networks are probably the
most important, or at least the most hyped, areas of computing at the moment. This
and the following chapter introduce the general concepts associated with TCP/IP-
based networks and in particular the knowledge required to connect and use Linux
computers to those networks.
This chapter examines how you connect a Linux machine and configure it to provide
basic network connections and services for other machines. Higher level network
applications, such as file sharing and web servers, and how they work and what you
can do with them, is the topic for the following chapter.
This chapter contains the following topics:
· Overview
Provides an overview of connecting a Linux machine to a network.
· TCP/IP Basics
A brief introduction to the fundamentals of TCP/IP networking.
· Hardware
Quick coverage of the hardware which can be used for networking.
· Kernel support
· Network configuration
Other Resources
As you might expect, there is a large amount of information about creating and
maintaining TCP/IP networks on the Internet. The following is a small list of some of
that material:
· HOWTOs
Linux Networking-HOWTO describes how to install and configure the Linux
networking software and associated tools. Linux Networking Overview HOWTO


provides an overview of the networking capabilities of Linux and provides
pointers to further information. Multicast over TCP/IP HOWTO, DNS HOWTO
covers the configuration of the Domain Name Service on Linux, Ethernet
HOWTO, IPX HOWTO covers the installation on Linux of the network protocol
used by Novell, IP Masquerade HOWTO, ISP Hookup HOWTO, PLIP Install
HOWTO covers how to connect Linux boxes using null parallel cables, PPP
HOWTO, Asymmetric Digital Subscriber Loop mini-HOWTO, Bridge mini-
HOWTO, Bridge+Firewall mini-HOWTO, Cipe+Masquerading mini-HOWTO,
IP Alias mini-HOWTO, IP Subnetworking mini-HOWTO, Leased Line mini-
HOWTO, Token Ring mini-HOWTO, VPN mini-HOWTO, Linux Modem
Sharing mini-HOWTO.
· LDP Guides
The Linux Installation and Getting Started Guide’s Chapter 6 covers networking.
Systems Administration Chapter 16: Networks: The Connection
Page 376
· The major one is the Linux Network Administrators Guide. It was actually
published by O'Reilly and Associates ( but is also freely
available as part of the Linux Documentation Project.
· Linux network project
Development on the Linux networking code is an on-going project. The project
leader maintains a web site which contains information about the current
developments. It's located at
· comp.os.linux.networking
A newsgroup specifically for discussions about Linux networking.
· TCP/IP introduction and administration
Documents produced by Rutgers University. Available from
/> with the filenames
tcp-ip-intro
and
tcp-

ip-admin
as either Word documents or postscript files. Should also be present on
the course website/CD-ROM.
· RFC Database
RFCs (Request for comments) are the standards documents for the Internet. A
web-based interface to the collection of RFCs is available from
/>
· Linux for an ISP
A number of Internet Service Providers from throughout the world use Linux
servers. There is a web page which maintains a list of links of interest to these
folk. It is available at
/> Some of the links are
dated.
The Overview
This chapter introduces the process and knowledge for connecting a Linux machine to
a TCP/IP network. There are many other types of networking protocols, but TCP/IP
is the protocol family on the Internet, so that is the one we concentrate on.
Creating a TCP/IP network does not necessarily mean you are connected to the
Internet. You can have a TCP/IP network between the two computers you have at
home.
What you need
In order to create some sort of TCP/IP network using Linux, you will need the
following:
· Networking hardware
You will need to make some sort of connection between the machines on your
network so they can communicate. Linux supports a wide range of networking
hardware. You can only use networking hardware that Linux supports (unless you
want to start writing device drivers).
· Appropriately configured kernel
To use your network hardware, the kernel must contain the appropriate device

driver or have access to an appropriate module. The kernel also requires a number
of other components which provide necessary low-level support for networking.
If you are using some sort of strange hardware, you will need to make sure you
have any appropriate kernel modules installed or may even need to recompile the
kernel to include support for your hardware.
· Network configuration tools
These should be already present on most Linux systems, and are used to configure
networking.
Systems Administration Chapter 16: Networks: The Connection
Page 377
· Network applications
These are the topic of the next chapter and again, most are supplied with the
common Linux distributions. These provide the higher level services such as
email, web and file sharing.
· Network information
This information is necessary to configure your system on the network. It
includes your machine’s IP address, the network address, the broadcast and
netmask addresses, the router address and the address of your DNS server.
What you do
To install your Linux box onto a network, you move on up the layers with steps
something like the following:
· Obtain the appropriate hardware
· Connect it to your system
· Configure your kernel to recognise the hardware
· Configure the network software
· Test the connection
TCP/IP Basics
Before going any further it is necessary to introduce some of the basic concepts
related to TCP/IP networks. An understanding of these concepts is essential for the
next steps in connecting a Linux machine to a network. If you find the following too

confusing or disjointed please refer to some of the other resources mentioned at the
start of this chapter. The concepts introduced in the following include:
· hostnames
Every machine (also known as a host) on the Internet has a name. This section
introduces hostnames and related concepts.
· IP addresses
Each network interface on the network also has a unique IP address. This section
discusses IP addresses, the components of an IP address, subnets, network classes
and other related issues.
· Name resolution
Human beings use hostnames while the IP protocols use IP addresses. There must
be a way, name resolution, to convert hostnames into IP addresses. This section
looks at how this is achieved.
· Routing
When network packets travel from your computer to a web site in the United
States, there are normally a multitude of different paths that packet can take. The
decisions about which path it takes are performed by a routing algorithm. This
section briefly discusses how routing occurs.
Hostnames
Most computers on a TCP/IP network are given a name, usually known as a host
name (a computer can be known as a host). The hostname is usually a simple name
used to uniquely identify a computer within a given site. A fully qualified Internet
host name, also known as a fully qualified domain name (FQDN), uses the following
format:
hostname.site.domain.country
Systems Administration Chapter 16: Networks: The Connection
Page 378
·
hostname


A name by which the computer is known. This name must be unique to the site on
which the machine is located.
·
site

A short name given to the site (company, University, government department etc)
on which the machine resides.
·
domain

Each site belongs to a specific domain. A domain is used to group sites of similar
purpose together (Table 16.1 provides some examples). Strictly speaking, a
domain name also includes the country code.
·
country

Specifies the actual country in which the machine resides. Table 16.2 provides an
example of some country names. You can see a list of the country codes at


For example, the CQU machine
jasper's
fully qualified name is
jasper.cqu.edu.au
, where
jasper
is the hostname,
cqu
is the site name, the domain
is edu and the country is

au
.

Domain Purpose
edu

Educational institution, university or school
com

Commercial company
gov

Government department
net

Networking companies
Table 16.1
Example Internet domains

Country code Country
nothing or
us

United States
au

Australia
uk

United Kingdom

in

India
ca

Canada
fr

France
Table 16.2
Example Country Codes
hostname
Under Linux, the hostname of a machine is set using the
hostname
command. Only
the root user can set the hostname. Any other user can use the
hostname
command to
view the machine's current name.
root@faile david]# hostname
faile.cqu.edu.au
[root@faile david]# hostname fred
[root@faile david]# hostname
fred
Changes to the hostname performed using the
hostname
command will not apply
after you reboot a Red Hat Linux computer. Red Hat Linux sets the hostname during
startup from one of its configuration files,
/etc/sysconfig/network.

This is the
file which is changed by the GUI tools provided with Red Hat. If you wish a change
in hostname to be retained after you reboot, you will have to change this file.
Systems Administration Chapter 16: Networks: The Connection
Page 379
Qualified names
jasper.cqu.edu.au
is a fully qualified domain name and uniquely identifies the
machine
jasper
on the CQU campus to the entire Internet. There cannot be another
machine called
jasper
at CQU. However there could be another machine called
jasper
at James Cook University in Townsville (its fully qualified name would be
jasper.jcu.edu.au
).
A fully qualified name must be unique to the entire Internet. Which implies every
hostname on a site should be unique.
Not qualified
It is not always necessary to specify a fully qualified name. If a user on
aldur.cqu.edu.au
enters the command
telnet

jasper,
the networking software
assumes that because it isn't a fully qualified hostname, the user means the machine
jasper

on the current site (
cqu.edu.au
).
IP/Internet addresses
Alpha-numeric names, like hostnames, cannot be handled efficiently by computers, at
least not as efficiently as numbers. For this reason, hostnames are only used for us
humans. The computers and other equipment involved in TCP/IP networks use
numbers to identify hosts on the Internet. These numbers are called IP addresses.
This is because it is the Internet Protocol (IP) which provides the addressing scheme.
IP addresses are currently 32 bit numbers.
IPv6
the next generation of IP uses 128 bit
addresses. IP addresses are usually written as four numbers separated by full stops
(called dotted decimal form), for example
132.22.42.1
. Since IP addresses are 32
bit numbers, each of the numbers in the dotted decimal form are restricted to between
0-255 (32 bits divided by 4 numbers gives 8 bits per number, and 255 is the biggest
number you can represent using 8 bits). This means that
257.33.33.22
is an invalid
address.
Dotted quad to binary
The address
132.22.42.1
in dotted decimal form is actually stored on the computer
as
10000100 00010110 00101010 00000001
. Each of the four decimal numbers
represents one byte of the final binary number as Figure 16.1 shows:






Figure 16.1
Dotted quad to binary

The conversion from dotted quad to binary (and back again) is important for some of
the following concepts.
10000100 00010110 00101010 00000001

132.22.42.1
Systems Administration Chapter 16: Networks: The Connection
Page 380
Networks and hosts
An IP address actually consists of the following two parts:
· a network portion
This is used to identify the network that the machine belongs to. Hosts on the
same network will have this portion of the IP address in common. This is one of
the reasons why IP masquerading is required for mobile computers (for example
laptops). If you move a computer to a different network, you must give it a
different IP address which includes the network address of the new network it is
connected to.
· the host portion
This is the part which uniquely identifies the host on the network.


Figure 16.2
Hostid and netid of an IP address

As Figure 16.2 shows, the network portion of the address forms the high part of the
address (the bit that appears on the left hand side of the number). The size of the
network and host portions of an IP address is specified by another 32 bit number
called the
netmask
(also known as the subnet mask).
To calculate which part of an IP address is the network and which is the host, the IP
address and the subnet mask are treated as binary numbers (see example below). Each
bit of the subnet mask and the IP address are compared and:
· if the bit is set in both the IP address and the subnet mask, then the bit is set in the
network address
· if the bit is set in the IP address but not set in the subnet mask, then the bit is set in
the host address.
For example
IP
Address
138.77.37.21 10001010 01001101 00100101 00100101
Netmask
255.255.255.0 11111111 11111111 11111111 00000000


Network
Address
138.77.37.0 10001010 00100101 01001101 00000000
Host
Address
0.0.0.21 00000000 00000000 00000000 00100101

Four bytes make up the IP address divided (unequally,
depending on settings) into netid and hostid



Netid Hostid
Systems Administration Chapter 16: Networks: The Connection
Page 381
The Internet is a network of networks
The structure of IP addresses can give you some idea of how the Internet works. It is a
network of networks. You start with a collection of machines all connected via the
same networking hardware, a local area network. All the machines on this local area
network will have the same network address, each machine also has a unique host
address.
The Internet is formed by connecting a lot of local area networks together.
For example
In Figure 16.3 there are two networks,
138.77.37.0
and
138.77.36.0
. These are
two networks on the Rockhampton campus of CQU and both use ethernet as their
networking hardware. This means that when a computer on the
37
subnet (the
network with the network address
138.77.37.0
) wants to send information to another
computer on the
37
subnet, it simply uses the characteristics of ethernet. The
information is placed on the ethernet network and gets broadcasted to every ethernet
card on the network. The ethernet card which has the appropriate address is the only

one which “accepts” the information.
However, if the machine
138.77.37.37
wants to send information to the machine
138.77.36.15,
it's a bit more complex. Since both computers are on separate
networks (one on the
37
subnet and the other on the
36
subnet), the machine
138.77.37.37
just can't send information to the machine
138.77.36.15
. Instead it
has to use a gateway machine (only rarely is the gateway machine a computer, but it
can be). The gateway machine has two network connections; one connection to the
138.77.37.0
network and the other to the
138.77.36.0
network.
It is via this dual connection that the gateway acts as the connection between the two
networks. The gateway knows that it should grab any and all packets on the
138.77.36.0
network destined for the
138.77.37.0
network (and vice versa). When
it grabs these packets, the gateway machine transfers them from the network device
connected to the sending network to the network device connected to the receiving
network.

Figure 16.3
A simple gateway

This process is repeated for other networks. Each network is then connected to each
other via devices called routers, or perhaps gateways. This is a very simple example.
Systems Administration Chapter 16: Networks: The Connection
Page 382
Assigning IP addresses
Some IP addresses are reserved for specific purposes and you should not assign these
addresses to a machine. Table 16.3 lists some of these addresses.
Address Purpose
xx.xx.xx.0

Network address
xx.xx.xx.1

Gateway address *
xx.xx.xx.255

Broadcast address
127.0.0.1
Loopback address
* this is not a set standard
Table 16.3
Reserved IP addresses
As mentioned above, 127.0.0.1 is a special IP address. It refers to the local host (or
the loopback address). The local host allows software to address the local machine in
exactly the same way it would address a remote machine. For those of you without
network connections, the localhost will be the only method you can use to experiment
with the concepts introduced in this and the following chapter.

As shown in the previous examples, gateways and routers are able to distribute data
from one network to another because they are actually physically connected to two or
more networks through a number of network interfaces. Figure 16.3 provides a
representation of this.
The machine in the middle, the gateway machine, has two network interfaces. One
has the IP address
138.77.37.1
and the other
138.77.36.1
(it is common practice
for a network’s gateway machine to have the host id 1, but this is by no means
compulsory).
By convention, the network address is the IP address with a host address that is all 0's.
The network address is used to identify a network. For example Figure 16.3 showed
two networks
138.77.37.0
and
138.77.36.0
.
The broadcast address is the IP address with the host address set to all 1's and is used
to send information to all the computers on a network. It is typically used for routing
and error information.
Network classes
During the development of the TCP/IP protocol, stack IP addresses were divided into
classes. There are three main address classes, A, B and C. Table 16.4 summarises the
differences between the three classes. The class of an IP address can be deduced by
the value of the first byte of the address.
Class First byte value Netmask Number of hosts
A 1 to 126 255.0.0.0 16 million
B 128 to 191 255.255.0.0 64,000

C 192 to 223 255.255.255.0 254
Multicast 224 – 239 240.0.0.0
Table 16.4
Network classes
If you plan on setting up a network that is connected to the Internet, the addresses for
your network must be allocated to you by central controlling organisation. You can't
just choose any set of addresses you wish, since chances are they are already taken by
some other site.
Systems Administration Chapter 16: Networks: The Connection
Page 383
If your network will not be connected to the Internet, you can choose from a range of
private addresses which have been set aside for this purpose. These addresses are
shown in Table 16.5.
Network class Addresses
A 10.0.0.0 to 10.255.255.255
B 172.16.0.0 to 172.31.255.255
C 192.168.0.0 to 192.168.255.255
Table 16.5
Networks reserved for private networks
Subnets
Central Queensland University has a class B network address,
138.77.0.0
. This
would imply that you could make the following assumptions about the IP address
138.77.1.1.
The network address is
138.77.0.0
and that the host address is
1.1
,

this is after all how a class B address is defined.
If you did make these implications you would be wrong.
CQU has decided to break its available IP addresses into further networks, called
subnets. Subnetting works by moving the dividing line between the network address
bits and the host address bits. Instead of using the first two bytes for the network
address, CQU uses subnetting to use the first three bytes. This is achieved by setting
the netmask to
255.255.255.0
.
This means that the address
138.77.1.1
actually breaks up into a network address
138.77.1.0
and a host address of
1
. The network
138.77.1.0
is said to be a subnet
of the larger
138.77.0.0
network.
Why subnet?
Subnetting is used for a number of reasons including:
· security reasons
Using Ethernet, all hosts on the same network can see all the packets on the
network. So it makes sense to put the computers in student labs on a different
network to the computer on which student results are placed.
· physical reasons
Networking hardware, like ethernet, has physical limitations. You can't put
machines on the Mackay campus on the same network as machines on the

Rockhampton campus (they are separated by about 300 kilometres).
· management and political reasons
There may be departments or groups within an organisation that have unique
needs or want to control their own network. It is far easier to manage a smaller
network of about 250 computers than a single network with 16 000. Subnetting
allows separate networks to be allocated to different departments.
· hardware and software differences
Someone may wish to use completely different networking hardware and
software.

"Strange" subnets
Generally, subnet masks are byte oriented, for example
255.255.255.0
. This means
that the divide between the network portion of the address and the host portion occurs
on a byte boundary. However it is possible and sometimes necessary to use bit
oriented subnet masks, for example
255.255.255.224
. Bit oriented implies that
this division occurs within a byte.
Systems Administration Chapter 16: Networks: The Connection
Page 384
For example, a small company with a class C Internet address might use the subnet
mask
255.255.255.224
. The following example demonstrates how this netmask is
applied.
IP
Address
192.168.98.44 11000000 10101000 01100010 00101100

Netmask
255.255.255.224 11111111 11111111 11111111 11100000


Network
Address
192.168.98.32 11000000 10101000 01100010 00100000
Host
Address
0.0.0.12 00000000 00000000 00000000 00001100

This example shows that there are now only 5 bits available for a host address so there
can only be 32 hosts on each subnet.
Exercises
16.10.
Complete the following table by calculating the network and host
addresses.

IP address Subnet mask Network address Host address
178.86.11.1

255.255.255.0


230.167.16.132

255.255.255.192


132.95.132.5


255.255.240.0


Name resolution
We have a problem. People will use hostnames to identify individual computers on
the network, while the computers use the IP address. How are the two reconciled?
When you enter
/> on your web browser, the first thing the
networking software must do is find the IP address for
www.lycos.com
. Once it has
the IP address, it can connect to that machine and download the web pages.
The process of taking a hostname and finding the IP address is called name
resolution.
Methods of name resolution
The two methods that can be used to perform name resolution are:
· the
/etc/hosts
file
· the Domain Name Service
Systems Administration Chapter 16: Networks: The Connection
Page 385
/etc/hosts
One way of performing name resolution is to maintain a file that contains a list of
hostnames and their equivalent IP addresses. Then when you want to know a
machine's IP address, you look up the file.
Under UNIX, this file is
/etc/hosts
.

/etc/hosts
is a text file with one line per host.
Each line has the format:
IP_address hostname aliases
Comments can be indicated by using the hash
#
symbol. Aliases are used to indicate
shorter names or other names used to refer to the same host.
For example
The hosts file of the machine
aldur
looks like this:
# every machine has the localhost entry
127.0.0.1 localhost loopback
138.77.36.29 aldur.cqu.edu.au aldur
138.77.1.1 jasper.cqu.edu.au jasper
138.77.37.28 pol.cqu.edu.au pol
Problems with /etc/hosts
When a user on
aldur
enters the command
telnet

jasper.cqu.edu.au
the
software first looks in the hosts file for an entry for
jasper
. If it finds an entry, it
obtains
jasper

's IP address and then can execute the command.
What happens if the user enters the command
telnet

knuth
? There isn't an entry
for
knuth
in the hosts file. This means the IP address of
knuth
can't be found and so
the command can't succeed.
One solution would be to add an entry in the hosts file for every machine the users of
aldur
wish to access. With over two million machines on the Internet it should be
obvious that this is not a smart solution.
Domain name service (DNS)
The following reading on the DNS was taken from

In the early days of the Internet, all host names and their associated IP addresses were
recorded in a single file called
hosts.txt
, maintained by the Network Information
Centre in the USA. Not surprisingly, as the Internet grew so did this file, and by the
mid-80's it had become impractically large to distribute to all systems over the
network, and impossible to keep up to date. The Internet Domain Name System
(DNS) was developed as a distributed database to solve this problem. Its primary goal
is to allow the allocation of host names to be distributed amongst multiple naming
authorities, rather than centralised at a single point.
DNS structure

The DNS is arranged as a hierarchy, both from the perspective of the structure of the
names maintained within the DNS, and in terms of the delegation of naming
authorities. At the top of the hierarchy is the root domain "." which is administered by
the Internet Assigned Numbers Authority (IANA). Administration of the root domain
gives the IANA the authority to allocate domains beneath the root, as shown in the
diagram below:
Systems Administration Chapter 16: Networks: The Connection
Page 386

The process of assigning a domain to an organisational entity is called delegating, and
involves the administrator of a domain creating a sub-domain and assigning the
authority for allocating sub-domains of the new domain the subdomain's
administrative entity.
This is a hierarchical delegation, which commences at the "root" of the Domain Name
Space ("."). A fully qualified domain name, is obtained by writing the simple names
obtained by tracing the DNS hierarchy from the leaf nodes to the root, from left to
right, separating each name with a stop ".", for example:
fred.xxxx.edu.au

is the name of a host system (
fred
) within the
XXXX
University (
xxxx
), an educational
(
edu
) institution within Australia (
au

).
The sub-domains of the root are known as the top-level domains, and include the
edu

(educational),
gov
(government), and
com
(commercial) domains. Although an
organisation anywhere in the world can register beneath these three-character top
level domains, the vast majority that have are located within, or have parent
companies based in, the United States. The top-level domains represented by the ISO
two-character country codes are used in most other countries, thus organisations in
Australia are registered beneath
au
.
The majority of country domains are sub-divided into organisational-type sub-
domains. In some countries two character sub-domains are created (for example
ac.nz
for New Zealand academic organisations), and in others three character sub-
domains are used (for example
com.au
for Australian commercial organisations).
Regardless of the standard adopted, each domain may be delegated to a separate
authority.
Organisations that wish to register a domain name, even if they do not plan to
establish an Internet connection in the immediate short term, should contact the
administrator of the domain which most closely describes their activities.
Even though the DNS supports many levels of sub-domains, delegations should only
be made where there is a requirement for an organisation or organisational sub-

division to manage their own name space. Any sub-domain administrator must also
demonstrate they have the technical competence to operate a domain name server
(described below), or arrange for another organisation to do so on their behalf.
Domain Name Servers
The DNS is implemented as collection of inter-communicating nameservers. At any
given level of the DNS hierarchy, a nameserver for a domain has knowledge of all the
immediate sub-domains of that domain.
For each domain there is a primary nameserver, which contains authoritative
information regarding Internet entities within that domain. In addition Secondary
nameservers can be configured, which periodically download authoritative data from

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×