Exercise on IP Routing

  1. Log into your host. Run "ip addr" to inspect its IP address and write down. Suppose it is "172.17.0.6". Let's call it "Alpha Host".
  2. Run "ping -c 3 172.17.0.6" to ping itself. (The option "-c" specifies the number of ICMP packets to send. This saves the trouble to press Ctrl-C to stop ping.) You may observe that the TTL (Time-to-Live) is 64. This implies that this packet does not go through any itermediate routers.
  3. Run "ping -c 3 10.22.1.254". This is a host inside the 3rd Building of Science and Technology. You may observe that the TTL is 63.
  4. Run "ping -c 3 lilina.csie.ncnu.edu.tw". This is a host in the Computer Center. You may observe that the TTL is 62.
  5. Run the following commands and see whether the results are consistent with what you expected:
    1. traceroute 172.17.0.6
    2. traceroute 10.22.1.254
    3. traceroute lilina.csie.ncnu.edu.tw
  6. In this exercise we created another host for you. It is running on port 230xx. Let's call it "Beta Host". If you connect to your Alpha Host via "ssh USERNAME@acm2.ncnu.net -p 22032", then you connect to your Beta Host via "ssh USERNAME@acm2.ncnu.net -p 23032".
  7. The login password on Beta Host is the same as Alpha Host. Actually I don't know your password on Alpha Host. I simply copied the 2nd field in /etc/shadow on Alpha Host to Beta Host. Therefore, if you change the password on Alpha Host today, the password on Beta Host is still the old one. They are independent. We shall have a future topic about NIS and NFS. You will learn how to "synchronize" the password on many hosts then.
  8. After you log into your Beta Host, run "ip addr" to inspect and write down its IP address. Suppose it is 172.17.0.17.
  9. On Beta Host, run "ip route". You will see two entries:
    default via 172.17.0.1 dev eth0 
    172.17.0.0/16 dev eth0
  10. The second entry refers to the same subnet as your Beta Host. (This is a Class B network, right?) Your host can reach all hosts within this subnet directly, without going through a router. For destination hosts not inside this subnet, your host will send packets via the default route, and the router will forward the packets to their destinations for your host.
  11. Run "ip route" to confirm that you have a default route. Run "ping -c 3 dns.google" to verify that default route is working.
  12. Run "sudo ip route delete default via 172.17.0.1" to delete the default route. Run "ip route" to confirm that only one route to local subnet is in your routing table.
  13. Run "ping -c 3 dns.google" again. It will complain "Temporary failure in name resolution". This implies that it cannot reach its DNS server (163.22.2.1).
    1. You can inspect /etc/resolv.conf to see your default DNS server.
    2. Because 163.22.2.1 is not in the same subnet as you, you must go through a router to reach it. Unfortunately, you just deleted that default route.
  14. Run "sudo ip route add 163.22.0.0/16 via 172.17.0.1". Now "ip route" shows that you have two routing entries. "host dns.google" also shows that you can query the IP address of dns.google from your DNS server. Running "ping -c 3 dns.google" now gives you a different error message: "Network is unreachable".
  15. If you want, you can add a routing entry for a single host only. Run "sudo ip route add 8.8.8.8/32 via 172.17.0.1", and "ping -c 3 dns.google" shows that you can reach dns.google now.
  16. However, there are many hosts all over the world. If you add one entry for each host, the size of your routing table will be terribly large. Therefore, we usually add a "default route" to simplify the routing table. Now let's add it back by "sudo ip route add default via 172.17.0.1".