Last Update By Kim - June 21, 2020
As covered in the article Network Devices, the main purpose of a router is to facilitate communication between networks. That usually means that each interface is part of a different network. Routers operate at Layer 3 of the OSI Model, which means it looks at the Layer 3 header for the source and destination IP.
Routers enable communication between networks by maintaining what is called the routing table. The table
contains paths to all networks the router knows how to reach. These paths are known as routes and they
are usually shared dynamically between routers, so when a destination network is not directly connected
to a router it knows where to forward it to the next router.
There are multiple options for a router to populate it’s routing table. There are static where you manually enter
all routes and dynamic where a protocol automatically shares the routes and networks between the routers.
It’s important to remember that if a router receives a packet which is not present in it’s routing table then the
packet gets dropped immediately. From the routers perspective, the routing table is a map of every network that exists.
Therefore when it receives a packet destined to a network it does not know about then the network must not exist.
Every time a router receives a packet, it will consult its routing table to determine how to forward the packet.
Let’s look an example of a simple network and how a router would populate it’s routing table:
Each circle represents a different network. From the perspective of Router 1 (R1) it can only see two networks:
“192.168.1.0” and “172.16.1.0”. That’s easy for it to figure out because it’s directly connected and therefore
knows how to send and respond to traffic to those networks respectively. The router would populate it’s routing
table by the network address, subnet mask and interface.
However if Host A wants to communicate with Host B then R1 would be in trouble because the network 192.168.2.0
is not directly connected to it. If it’s not specified in some way then R1 would just drop the packet. To resolve
this you could manually type in the network address or you could use a dynamic routing protocol, so the routers
would share it’s routing information automatically. No matter what option you choose it would populate the routing
table in the same way.
After manually entering the route on R1 for the network 192.168.2.0 it would then populate it's routing table as follows:
Network | Subnet Mask | Next Hop | Interface |
---|---|---|---|
172.16.1.0 | 255.255.255.0 | - | Directly Connected |
192.168.1.0 | 255.255.255.0 | - | Directly Connected |
192.168.2.0 | 255.255.255.0 | 172.16.1.2 | Fa0/1 |
The last row explains how to reach the network of Host B. "Next Hop" is the IP address of R2
and the "interface" column is R1 towards R2. Don't worry about network addresses and subnet masks. That will be explained
in another article. For now we're just focusing on how a router thinks and routes packets.
If you're completly lost with this network topology then here's a quick explation.
"Fa0/1" and "Fa0/2" is the name of the interfaces. The ".1" and ".2" is the abbreviation IP address assigned
to each interface. For instance the full IP address is "192.168.1.1" and "192.168.1.2" in the 192.168.1.0 network.