Lab 6: Routing
Objective
The objective of this tutorial is to show you how to setup a router. Meaning
one machine will use another to access to the internet. In our case, one
VM will be the router to another VM will that be a host which connects to the
internet through the router.
Introduction
In order to do this tutorial you will need two virtual machines on your
computer. To accomplish this do, the following:
- Check if there are 5G of disk space residing in
/extra
.
- Start the VMWare program, but do NOT power on your VM. From menu in the
upper-left corner, select VM/Settings and add a secondary Ethernet adaptor.
Select Host-only for the network connection
- Terminate the VMWare session
- Duplicate the original VM by running the command
# cp -av
/extra/<vmname> /extra/<vmnare>2
Now, power on both VMs, one at a time. When you boot the second one you
will be asked to create a new ID for the VM, just click "CREATE".
Procedures
Configure the VMs
To test to see if the router-host setup is correctly, first on the Router VM
run # tcpdump -i eth1
, then on the Host VM run
# ping -c 3 74.125.19.99
If the ping was successful, then the tcpdump will have
captured all the ping packets from the host VM.
Wrapping up the tutorial
If you wish to ping "normal" websites like www.google.com, we need to change
the nameserver to 138.23.169.10
by editting the
/etc/resol.conf
file on both VMs. However, this will only hold
true for this session as the DHCP server will overwrite this on boot up.
One more command is needed to ping www.goggle.com from the Host VM. We need to
disable firewall rules on the Router VM to allow name resolution on the Host
VM: # /etc/init.d/iptables stop
Making changes persistent
All the changes we have done thus far are only TEMPORARY! It will revert
back to "default" upon a system restart. In order to make this permanent we
need to edit the files that configure the network on bootup.
We need to edit the files /etc/sysconfig/network,
/etc/sysconfig/network-scripts/ifcfg-eth0,
/etc/sysconfig/network-scripts/ifcfg-eth1
- The Router VM
- The previously listed files show be editted to look like this,
respectively
- The Host VM
- The previously listed files show be editted to look like this,
respectively
Additionally, we need to make the IP Forwarding permanent. To do this, we need
to edit the file /etc/sysct1.conf
. Change
net.ipv4.ip_forward
to 1.
Conclusion
All that's left to do is reboot both VMs, and now the host VM will route to
your router VM. Future tutorials will be based upon this setup. So if you wish
to continue my line of tutorials, be sure to have this up and running
correctly. Also, if you still want to ping www.google.com you will need to
repeat the steps that changes the nameserver and modify the firewall once
again.
Further Reading
If you wish to know the inner-workings of routing algorithms:
An FAQ on the wonderful DHCP
Glossary
router
"A router is a computer whose software and hardware are usually tailored to
the tasks of routing and forwarding information. With appropriate software, a
PC can act as a router."
(source: www.wikipedia.org)
routing
"Routing (or routeing) is the process of selecting paths in a network along
which to send data or physical traffic. Routing is performed for many kinds of
networks, including the telephone network, the Internet, and transport
networks."
"Routing directs forwarding, the passing of logically addressed packets from
their source toward their ultimate destination through intermediary nodes;
typically hardware devices called routers, bridges, gateways, firewalls, or
switches. Ordinary computers with multiple network cards can also forward
packets and perform routing, though they are not specialized hardware and may
suffer from limited performance. The routing process usually directs forwarding
on the basis of routing tables which maintain a record of the routes to various
network destinations. Thus constructing routing tables, which are held in the
routers' memory, becomes very important for efficient routing."
(source: www.wikipedia.org)
host (network)
"In computer networking, a host or host computer is a computer connected to
the Internet, or sometimes other computer networks[1]. A host computer can host
information as well as client and/or server software."
"Every Internet host has a unique IP address, including a host address part.
The host address is assigned either manually by the computer administrator, or
automatically at start-up by means of the Dynamic Host Configuration Protocol
(DHCP)."
"Every host is a network node (i.e. a network device), but every node is not a
host. Network nodes such as modems and network switches are not assigned host
addresses, and are not considered as hosts. Devices such as network printers
and hardware routers are assigned IP host addresses, but since they are not
general-purpose computers, they are sometimes not considered as hosts in the
literature."
(source: www.wikipedia.org)
ping
"Ping is a computer network tool used to test whether a particular host is
reachable across an IP network; it is also used to self test the network
interface card of the computer. It works by sending ICMP "echo request"
packets to the target host and listening for ICMP "echo response" replies.
Ping estimates the round-trip time, generally in milliseconds, and records any
packet loss, and prints a statistical summary when finished."
(source: www.wikipedia.org)
Dynamic Host Configuration Protocol (DHCP)
"Dynamic Host Configuration Protocol (DHCP) is a protocol used by networked
devices (clients) to obtain various parameters necessary for the clients to
operate in an Internet Protocol (IP) network. By using this protocol, system
administration workload greatly decreases, and devices can be added to the
network with minimal or no manual configurations."
(source: www.wikipedia.org)
Questions
- The outputs that show all the traffic from the Host VM go through the
Router VM.
Here's the traceroute of the Host through the Router. If you wish to see
the tcpdump of the Router while the Host pings an IP address, refer to earlier
in the tutorial at the end of the section "Configure the VMs".