Router is used to connect two or more LANs together. So what exactly we need to do to connect these LANs? Do we just plug in the cables? Or do we need to configure anything on the routers?
The answer depends on how we are connecting these networks to the routers. In short, if the LANs are directly connected to the router; there is no need for any configurations. The router will auto discover the networks that is directly connected to it. Meanwhile, if we are connecting multiple LANs to several routers that are more than ONE HOP away; then we need to configure routing to link up these routers. Another rule of thumb to know if we need to configure routers is to:
“check how many routers are there in the network topology — if there are TWO or more routers then we need to configure routing”
Directly Connected Networks (C)
A router have at least TWO or more interfaces. We can create ONE network on each interface on the router. When we connect one port of the router to another device; a switch or a PC — this is consider one LAN. If we connect the second port of the router to another PC; now we have 2 LANs.
These networks that are created by directly connected to the router; is called the Directly Connected Networks. So in this case, we say that this router currently has TWO directly connected networks. We will refer to Directly connected networks as (C) from here onwards; just like how router represents it in the routing table. (C) networks are plug and play; this means that when a new device is plugged into the router’s port; the router will be able to forward the packets to this device automatically.
The only two things concerns are:
1. make sure the right types of cable is used (check if a cross-over or a straight-through cable is needed)
2. we have assigned an IP address at the router’s interface that the cable is currently plugged in
Now, how many (C) do you think RouterX in the network below has?
Based on the network diagram, RouterX currently has 3 directly connected networks (which is color coded in yellow, green and red). That’s because the ‘SwitchX’ in LAN1 is directly connected to one of the port on RouterX. Similarly, PC0 is directly connected to RouterX in LAN2; and RouterY is directly connected to RouterX in LAN3.
But this does not means that RouterX can only talks to this three networks. In fact, RouterX can talk to any network as long as there is a route from RouterX to that destination network. Also, this does not mean that RouterX only have 3 interfaces; it’s just that some of the ports on RouterX is currently not connected to any devices.
Now, try to guess how many (C) does the RouterX in the (same but zoomed out) network below has?
Actually, RouterX still has the same number of (C); which is three at the moment despite there are a few more networks added to the topology. That’s because the new LAN4, LAN5 and LAN6 are not directly connected to RouterX. In this case, LAN4, LAN5 and LAN6 are called the remote networks. Before RouterX can reach these remote networks; we first need to configure routings on RouterX.
Showing Directly Connected Networks on Router
Tips: we can type ‘show ip route’ on RouterX to show all the directly connected networks instead of counting them manually. Using the same example network (we added the port labels and LAN info); we can simply go to RouterX and type the show ip route command in the CLI to get its routing table.
The figure below shows RouterX’s routing table.
Notice that there are 3 networks in the table annotated as ‘C’; which indicates directly connected networks. We will talk more about the routing table in other story.
A network is either directly connected to a router (C), or they are indirectly connected to the router through other routers. We call these networks the remote networks. Remember that we are looking in the point of view of one network; which is the RouterX in our example. Here, we says that LAN1–3 are (C) networks while LAN4–6 are remote networks to RouterX. In fact, the remote networks for RouterX are simply directly connected networks to some other routers.
For RouterX to reach any of the remote networks, we need to configure either static routing or dynamic routing on RouterX.
So, how do we find out if a network is remote network or directly connected to a router? The easy way is to look at the hop count.
The rule of thumb is if there is ONE or more hops between the source and destination networks; then routing is needed.
In networks, one hop is defined as one link between two routers. The hop count values increment by 1 every time a packet go through a router. In the figure shown below, we try to systematically list out all the networks in the topology, and then classify them into either a directly connected or a remote network.
We do so by counting the hop count from the source network to destination network. In this example, we consider LAN1 as the source network; so the hop count values is in the context of RouterX (the router of LAN1).
There are 6 LANs here. We need to check the hop count to reach LAN2-LAN6 (5 LANs) except for LAN1 itself. If we find there is more than 1 hop count between LAN1 to the destination LAN; then we know routing is needed. The results are shown in the table below (√ means routing is needed, x means routing is not needed).
We know that LAN2 and LAN3 is directly connected to the same RouterX, so we don’t have to count the hop values for LAN2 and LAN3. Meanwhile, we also know that we need to configure routes for LAN1 to talk to LAN4, LAN5, and LAN6.
In the next story, we will learn how to configure 3 static routes on RouterX to reach LAN4, LAN 5 and LAN6 from LAN1.