CPSC 441, Networking and Distributed Processing, Fall 2004
Lab 1: Introduction to Linux Networking
FOR THE FIRST LAB IN EATON 116, you will install some software and configure some network services on the computers that you will be using throughout the term. You will also compile and run a tiny Java network client program.
There are computers on three tables in the lab. The class will divide into groups, and each group will have a table of its own. On the table, there will be a main "server" computer which will be shared by the group, plus one "client" computer for each person in the group. Currently, all the computers have a default installation of SuSE 9.1. Note that this is a newer version of SuSE than the one in use in the Math/CS lab. The root password for the computers will be written on the board during lab. There are no non-root users on the computers. I suggest that you change the root passwords. Everyone in a group should know the root password for that group's server computer.
Please use the computer that is on the left end of the table, as you face the blackboard, for your server computers. These computers have two ethernet cards, which will be important later in the term.
You will be able to access the computers remotely as long as you know their IP addresses. For example, to log in remotely to IP address 172.30.217.10 as root, use
ssh -X root@172.30.217.10from any Linux computer (or MacOS X and most UNIX computers). The "-X" will let you run GUI applications.
Software Installation
You should begin by installing some software on your server computer. This will take a while, so get it started and work on your other computers while it is running.
SuSE uses a program called yast2 for configuration. Start the program with a command on the command line, or select "YaST" from the "System" sub-menu of the Start menu.
You will do software installation over the network from an NFS (Network File System) server running on eck.hws.edu (IP 172.30.10.43). The software is in a directory named /suse on that server. Click on "Change Source of Installation" in YaST, and check that this server is listed as the installation source. Some of the computers might list SuSE CD's as the source -- in that case, switch the source to the NFS server. Ask for help if you need it.)
Next, click on "Install and Remove Software." This will (slowly) open a window where you can select software to be installed. You will need to install ethereal and java2 on all computers, since we will need them in later labs. It is easiest to find these using the "Search" Filter view of the available software. Just put a check next to any package that you want to install. On the server computer only, switch to the "Selections" filter, and check the "Simple Webserver with Apache2" selection. This will check off a variety of packages for installation. You can look for other packages that you would like to install, if you like. When you have selected all the packages that you want to install, click the "Accept" button. It will take a while to do the installation.
After the installation on the server finishes, you should apply any available updates to the installed packages. SuSE makes updates available to software packages on its CD's when security issues or bugs are discovered. The Apache web server package seems to be broken, so you will need to do at least that update. Click on "Online Update". When the window opens, click on "New Server," select "NFS" and click OK, then enter eck.hws.edu as the Server Name and /suse/YOU/update as the Directory on the Server, and click OK again. Back in the main window, click "Next" and when the list of available updates appears, click "Accept". The installation will take some time. (You might want to skip the kernel update; if you do install it, reboot the machine.)
Configuration
When the installation and update on the server are complete, it's time to configure some network services. Click on "Network Services" in the main YaST screen, and you will see a variety of network services that you can configure. (Note that playing with some of these can be dangerous. In particular, please don't configure a DHCP server!)
Do the following configurations:
- HTTP Server. All you need to do is set it to "Enabled," and click "Finish." This will start a Web server and set it up to be started whenever the computer boots. The server should be accessible at a web address that uses the IP number of the computer, such as http://172.30.217.10. Check that it is working!
- NTP Client. A client for NTP (Network Time Protocol) allows your computer to set its clock to a very accurate time that it obtains from an NTP server. Set the NTP Daemon to start "When Booting System," and set the NTP Server to 172.30.10.23 (This is the server math.hws.edu, but its better to use the IP number here.) When you click "Finish", you should see the clock on your computer jump to the exact time.
- If you want to send mail from the computer, configure the Mail Transport Agent. You want to configure a Permanent Connection, with an Outgoing Mail Server of mail.hws.edu. You do not want to "Accept remote SMTP connections, so leave the final screen unchanged before you click "Finish."
- Finally, configure Network Services (inetd). Inetd is the "network super daemon." It is a single program that listens for connections on many different ports. When it gets a request for a connection on a given port, it starts up the appropriate server program to handle the connection. The point of this is to avoid having a multitude of small server programs running that are only used occasionally. You should set Inetd to "Enabled" and then Toggle the Status of the "daytime stream tcp" service to "On". This is a very small service that we will use later in the lab, and it is the only inetd service that we require for now. (But you can look at what other services are available through inetd.)
Some Simple Network Monitoring
Please try out the following three programs:
The ifconfig command is used to set up and tear down the basic network configuration of a computer, such as the IP number. It is rarely used directly for this purpose; instead, it is called by system utilities when the computer is booted or halted. However, you can use it to display some basic information and statistics. Try it. Your computer's network interface is named "eth0," which stands for the first Ethernet connection on the computer. The ifconfig command tells you the IP address of this interface, the number of packets that have been transmitted (TX) and received (RX) since the computer was booted, and other information. (Note: Ordinary, non-root users can run this command as /sbin/ifconfig.)
The netstat command can be used to get information about active network ports and connections on the computer. Use "netstat -t" to see active TCP connections. Use "netstat -t -l" to see "listening sockets" that are waiting for connections from other computers. You will see a socket listening for ssh connections. On your server machine, after you configure the network services, you will see other listeners as well. Try "netstat -t" on math.hws.edu, which often has a bunch of open Web connections. (Add the option "-n" to see the output in terms of IP addresses and port numbers. Also, try "netstat -t -n -c".)
The host command can be used to look up the IP address for a given domain name. For example, use host math.hws.edu to find the IP address for math.hws.edu. It can also do a "reverse lookup" if you give it an IP address. For example, use host 172.30.217.101 to find the domain name that has IP address 172.30.217.101.
A Client Program in Java
To give you an idea of what a network client program can look like, here is a very, very simple example in Java. This program is a client for the daytime protocol. After compiling it, you could call it as "java DayClient 172.30.217.13" to contact the daytime service on the computer at IP address 172.30.217.13. (You could also use a domain name instead of an IP address.)
import java.net.*; import java.io.*; public class DayClient { public static void main(String[] args) { if (args.length < 1) { System.out.println("Usage: java DayClient <host_address>"); return; } try { Socket socket = new Socket(args[0],13); BufferedReader in = new BufferedReader( new InputStreamReader(socket.getInputStream())); String date = in.readLine(); System.out.println(date); socket.close(); } catch (Exception e) { System.out.println("Can't contact daytime service on " + args[0]); System.out.println("Error: " + e); } } }Compile and run this program to test the daytime service on your server computer. This will also test your java compiler installation. Instead of retyping the program, get a copy using this scp command, replacing "username" with your own user name:
scp username@cslab1.hws.edu:/classes/f04/cs441/DayClient.java DayClient.java
Assignment
This is group assignment. The students at each table should work together. This should be complete before class next Wednesday. There is nothing to turn in on paper.
First of all, I will test access to the daytime and web services on your server computer. I will also check that the time is exactly correct, as set by NTP. Please leave your server running so that I can do this.
Post your answers to the following questions on the Web server on your server machine. You can replace the index page for the server with your answers, or create a different index page with a link to the answers. (You will have to discover where the index page resides -- that is part of the assignment. Hint: Maybe you should have paid more attention when you were configuring network services in YaST.)
- What port number is used by the daytime service? How did you figure this out? (There are several ways you could do it.)
- In addition to eth0, what other interface is displayed by the ifconfig command? What is this interface? How did you figure it out?
- What is the error when you give the command java DayClient math.hws.edu? Why? What is the error when you give the command java DayClient foo.bar? Why? If you give the command java DayClient 172.30.217.1, you should see a longer delay before you get an error message. Can you figure out why?
- How many network client programs can you find pre-installed on your computer? (List them.)