Last modified 2/21/2007

Lab 2: Configuring a Network Router

The purpose of this lab is to join three network segments by configuring two routers between them. The three networks are one switch and two hubs. You will be using all 4 of the systems at a pod. The goal is to obtain connectivity between a host in Mordor with a host in the Shire by utilizing layer 3 routing. You will verify success by successfully pinging from one side of the network to the other. This lab assumes you are working at one of the pods in the lab in room 2504.
I strongly suggest that you read through this lab before doing it, and draw a picture of what is going on. Label the diagram with names and IP addresses. It will help you immensely.


Setting up a router involves 3 steps:
  1. Configuring appropriate IP addresses on the routers.
  2. Configuring the routing table of each router and host
  3. Turning on IP forwarding so that packets will travel through each router's two interfaces.
The commands we will be using for this lab are: Most of these commands require root access, so you will need to log on as root.


Part I

Use Elrond (yellow) as the router between the networks of Rivendell and The Shire. The first NIC card will interface (eth0) on the Rivendell network ( with an IP address of (netmask:
The second NIC will interface with The Shire network (, using an IP address of (netmask:
  1. Enter the command: ifconfig and verify that the IP settings are as specified above for your rivendell router. (If eth1 is not configured, make it so.)
    Note: this task is a repeat of the first lab.
  2. Make sure that the Frodo (purple) computer in The Shire is booted. Log on to that system and obtain its ip-address using ifconfig
  3. From the router on Rivendell, ping that ip-address using the command:
    ping ip-address
  4. Does it work?
    Try the following command:
    ping -I ip-address, where N is the Pod number.
    Does this work? Why or why not?
  5. Look at the routing table for the computer in the Shire that you just tried to ping by using the route command. Notice that the default route is
    The Shire computers don't know what to do with addresses from the network, so they get sent out the default route, not back to Elrond.
  6. Let's fix this problem by adding a new network and gateway to the Shire machine:
    route add -net netmask gw
    Note the gateway address - it's the address that is local to the Shire.
  7. Now go back and re-execute the ping command from Elrond:
    ping -I ip-address
    Does it work this time?
  8. Log on to the other computer on the Rivendell network, Legolas (blue).
  9. What is the default gateway?
    If there isn't one, what should it be?
  10. Set the default gateway on Legolas to be Elrond using the following command:
    route add default gw
  11. Now try to ping that same machine that's in the Shire:
    ping ip-address
    Does it work?
  12. If it doesn't work, it might be because ip_forwarding is not turned on. Back on Elrond, execute the following commands:
    cd /proc/sys/net/ipv4
    echo 1 > ip_forward
  13. Now you should be able to ping the Shire Computer.

Part II

We now have two separate network segments joined by the router Elrond. For a third network, we are going to use Mordor. Use Legolas as the router between Rivendell and Mordor. Make sue that there is a cable joining Legolas to the Mordor hub using the second NIC (eth1).
Remember, your goal is to get the Sauron computer to talk to Frodo in the Shire.
  1. Use ifconfig to configure the second NIC of the Rivendell/Mordor router.
  2. Turn on ip-forwarding by issuing the following commands:
    cd /proc/sys/net/ipv4
    echo 1 > ip_forward
  3. Check the default routes on the Mordor computer; it should point to your router.
  4. Are we done? Can you ping a machine in the Shire?
    Why doesn't it work?
    We've forgotten about the other machines in the network. They need to be able to send packets back to this new network!
  5. The Mordor Host: The routing table should contain a default route to the closest router.
    Remember to use the router's IP address that is on the Mordor network.
  6. The Mordor-Rivendell Router: What should the default route be?
    Think where most of the traffic will be going;
    route add default gw Elrond
  7. The Rivendell-Shire Router:
    We must configure this router to route packets back to Mordor.
  8. Use the route command to set the default Gateway to be on the Rivendell router:
    route add default gw
    Check the table to see that this has been done correctly.
  9. Add another route for the packets to be sent back to Mordor:
    route add -net netmask gw
  10. The Shire Host:
    The host in the Shire must also be told where to route packets destined for this new subnet:
    route add -net netmask gw
  11. Did we get everything? See if you can ping through all three networks. Make sure each computer knows what to do with packets from each of the three networks. Your ping packets should make two hops from Mordor to the Shire.
  12. Note1: You will not be able to ping opus or any internet computer from Mordor; why not?
  13. Note2: if you make errors in the routing tables, these errors may be cached even though you have corrected them. To flush the routing table cache, use the command:
    route -CF

Outputs to include in your Lab:

  1. Route table for the Shire host (172.30.4.XXX)
  2. Route table for the router between Rivendell and the Shire
  3. Route table for the router between Mordor and Rivendell
  4. Route table for the Mordor host (192.168.3.XXX)
  5. The successfull ping from the Mordor host to the Shire host.

Grading Rubric

20 Points possible
4 points for:
A correctly configured routing table for the host on the network (The Shire)
4 points for:
A correctly configured routing table for the router joining the network with the network (Celebrian or Elrond)
4 points for:
A correctly configured routing table for the router joining the network with the network (Sauron)
4 points for:
A correctly configured routing table for the host on the network (Mordor)
4 points for:
A successful ping making a 2-hop journey from Mordor to the Shire
or vice versa.