Chapter 9 - Networking
Quiz
1. Whatís the difference between a bridge, a router, and a gateway?
- A bridge is a device that connects two separate network segments
together as if they were a single segment, all packets from one segment
are passed to the other. A router connects two (or more) distinct network
segments together and only passes traffic to the another network if
its destination address is part of that network. A gateway is really
just a large-scale router as far as what it does with a data packet.
Gateways typically are used to connect disparate local area networks,
but functionally it performs the same function as a router. A gateway
might include some extra security capabilities to protect the local
network from the outside network.
2. Whatís a good way for a system administrator to tell people about important
events?
- If all the users are on a single machine, one could use the wall
command. However, in these days of distributed computing, this is rarely
feasible anymore. Today, electronic mail is one of the more practical
methods to broadcast information to a large group of people.
3. Why is ftp more powerful than rcp?
- The ftp command can be used to send files to any other computer
with an ftp daemon listening (which includes many other operating systems,
like VMS and Windows). The rcp command is limited to copying
files to another UNIX machine.
4. Describe some uses of common ports.
- Correct answers come from the /etc/services file. Some of the most
well known ports are TELNET at 21, FTP at 23, and SMTP at 25.
5. What does machine equivalence mean and how can you make use of
it?
- Machine equivalence is the notion used in the rsh, rcp,
and rlogin commands, which negates the need to specify a user
name and password in order to perform an operation. By declaring a machine
equivalence, it is assumed that the same users and groups are defined
on both machines and that a user who is logged in on one machine is
entitled to the same privileges on the other machine. This enables the
user to copy files and login from one machine to another without having
to provide a password, a convenience if allowed, but potentially a huge
security hole.
Exercises
9.1 Try out rcp and rsh as follows:
- Copy a single file from your local host to a remote host by using
rcp.
- Using rsh, obtain a shell on the remote host, and edit the
file that you just copied.
- Exit the remote shell, using exit.
- Using rcp, copy the file from the remote host back to the
local host.
[level: easy]
- If rcp is used properly, you will get no messages at all,
just another shell prompt. Using rsh, you will log in on the
remote machine and be able to type commands just as if you were logged
on locally. When you exit the remote shell, the shell prompt of your
original shell will be displayed again. When you copy the file back,
it will again display no messages but the modified file will be in your
directory.
9.2 Use telnet to obtain the time of day at several remote host sites.
Are the times accurate relative to each other? [level: medium]
- Look up the time service in /etc/services to find the port (you should
find port 13). You can telnet to port 13 on various hosts by
specifying 13 as the second argument to telnet (the first argument
is the remote host name to which to connect). Unless you happen to connect
to sites that all update their time from an accurate time server or
WWV clock, you will probably find that they do not all agree precisely.
Project
Write a shell script that operates in the background on two machines and
which ensures that the contents of a named directory on one machine is always
a mirror image of another named directory on the other machine. [level:
hard]
- Such a script would run in a loop where it would sleep some amount
of time and then check to see if files have changed. The check might
consist of using rsh to do an ls of the directory on the
remote machine and then diff to compare it to an ls listing
from the local machine. New files on either machine can be easily found
(present only in one of the two lists). The modification dates of files
that are present in both lists should be compared and the file with
the latest date should be considered the correct one. Another way to
do this would be to leave a bookmark file each time through the loop
and then use find to generate a list files that have been modified
since the last time the directory was examined. In both of these cases,
you will still need a way to find files that have been deleted. Ultimately
you may find that the best way is to maintain a full master list of
all the files, then you can identify new files, old files, and deleted
files.
|