CS70 Routing Table Assignment - Using Gateways

marrying 2 workstations/subnets to inter-communicate through a common gateway

 

Bring a formatted diskette to the lab. Have a lab technician enable you to boot the three Linux-configured machines needed for this assignment. You need

- in room B259, machine BCT028 plus a pair of the other machines

BCT028 is already pre-configured as a gateway. It has special routing so that it is a member of two different subnets at the same time. This is usually done with 2 ethernet cards, but it's possible to apply more than one address to a single ethernet card and simulate the 2-card case. Machine BCT028 for example has the following 2 addresses:

192.168.99.18
192.168.101.18

The netmask in all cases is 24 bits or 255.255.255.0. In other words these single addresses are part of a pool, and the netmask identifies what pool. Knowing the machine address alone isn't sufficient to identify the pool. For instance, "18" could be part of the pool that starts at 0 and goes through 31, the one that starts at 0 and goes through 127, or the one that starts at 16 and goes through 31. But the specified mask nails it down to the series of 256 addresses that start with 0. So it's

192.168.99.18 - member of (192.168.99.0 - 192.168.99.255) family
192.168.101.18 - member of (192.168.101.0 - 192.168.101.255) family

 

 

With this arrangement and a little help from the gateway, workstations in the red 99 network are potentially in touch with those in the blue 101 network (see circled pair). But this can happen only if the workstations' routing tables are informed of the possibilities.

In this assignment you will configure the routing tables of "circled pair." You will be successful when each of your pair can ping the other, using the "foreign" IP address from the opposite network that characterizes the other.

Please issue the following commands:

On the red workstation: On the blue workstation:
ifconfig eth0 down
<assign eth0 the address "192.168.99.30" w/24-bit netmask>
<add a route to the blue net through the gateway>
ifconfig eth0 down
<assign eth0 the address "192.168.101.40" w/24-bit netmask>
<add a route to the red net through the gateway>

To name the gateway in the route command you issue on each workstation, you can refer to it as a member of your particular network because it is indeed a fellow member. (In other words since the gateway has 2 addresses you have a choice-- use the "local" one.) Your route command then establishes that the gateway machine is to be used as a gateway, and names the other network as the destination that it leads to (be specific, don't use default routing). Recall the syntax of the route command:

lAdd route to a machine
route add –host 192.168.4.2 eth0
lAdd route to a group of machines (local)
route add –net 192.168.4.0 netmask 255.255.255.0 eth0
lAdd route to a group of machines (thru gateway)
route add –net 192.168.5.0 netmask 255.255.255.0 gw 192.168.4.1
lAdd route to “any and all” (default route)
route add default gw 192.168.4.1

When you have set up both machines correctly you will be able to ping either from the other and receive a reply. Once you are at that point, proceed to the instructions below to turn in your work.

Turning the assignment in

To grade you, I have a program for you to run. You can download "grade_gateway" here. (If you download it elsewhere than the lab and then wish to transport it onto the lab computers, the linux "mcopy" command will be useful. You will also need to use the "chmod" command. See below. When downloading, ensure that the software you use to download it-- your browser-- does not change it. The original file is 582 bytes in size, make sure the  downloaded file's size is no different.) Once you have "grade_gateway" on the workstation where you've done your work (either one), run it. It requires you give it a parameter on the command line. Please give it the exact user name you have on the remote Unix server (it won't be gradeable without an exact match). The program figures out whether it is running on 192.168.99.30 or 192.168.101.40. Once it knows, it tries to ping the other. If it's successful it produces a file named "gateway_assignment". I want you to then turn in your gateway_assignment file by ftp'ing it to the "assignments" subdirectory of your home directory on the remote Unix server.

Note this is an all-or-nothing assignment in the sense that until you get things right the program will produce no file, and you'll have nothing to turn in. On the other hand, the requirement is for you to issue merely 4 commands (the ones indicated in the above table). The focus of the assignment is the thought that goes into formulating the commands. Plan it out mentally before going to SMC.

Appendix: two useful linux commands, mcopy and chmod

If you want to move files around, it can be done on a DOS/Windows-formatted floppy. This lets you move files not only between linux machines but between a Windows machine and a linux machine. Insert the floppy in the drive of the linux machine. To copy a file from the floppy to the linux machine's current directory:

 mcopy a:<name of file on diskette>

To copy a file in the linux machine's current directory onto the floppy:

 mcopy <name of file> a:

Note the space between the filename and the a:.

After you copy a file you wish to execute onto a linux machine, it won't be executable until you make it so. The file we're interested in here is grade_gateway. You will need to issue:

 chmod +x grade_gateway

Thereafter, you can run grade_gateway (assumed to be in the current directory) by issuing:

 ./grade_gateway <your exact user name>

The leading ./ (period followed by slash) is a shorthand way to explicitly prefix the executable file's name with the current directory to ensure the shell (command processor) can locate the file in order to run it.