9.Layer 3 Routing Basic and Static Route
9.Layer 3 Routing Basic and Static Route
By Sean Ning
Routing Basics
“Routing is the process of selecting a path for traffic in a network or between or across multiple networks”
- Wikipedia
You can use show ip route to check the routing table of a Router or Layer 3 switch.
Can PC_A ping PC_B without configuring any static or dynamic routing on the Router?
Connected Route & Local Route
‘C’ identifies a directly connected network. Directly connected networks are automatically created when an interface is
configured with an IP address and activated.
Compare the obtained result and Host A’s subnet, Host A and B are in different subnet if the result is different
IP Routing Process (Different Subnet)
9. A packet is then created including the source address (host B’s IP) and destination address (host A’s IP).
10. Similarly, Host B finds destination IP is in remote network, host B sends an ARP request to look for the MAC address of its default
gateway.
11. Router responds the request and provide MAC address of g0/1 to host B,
12. Host B sends the ICMP packet to router interface g0/1.
13. Router looks up the destination address in its routing table and finds 10.10.10.0/24 network is directly connected to g0/0.
(Router discard packet if it cannot find destination address - When Ping fails most people think the packet never reach the
destination, but as we see here, that is not always the case)
14. Since MAC address of 10.10.10.2 is already cached from the original trip to Host B, the packet is forwarding to Host A via g0/0
without doing ARP query again
Configure Static Routes
Configure R1 and R2 so that Host A can ping Host B.
Only “C” & “L” route are installed into routing table after we configuring IP address of the router interfaces
Configure Static Routes
To add a static route to the routing table, type a command using the following syntax in global configuration mode:
ip route [destination_network] [mask] [ next_hop_address] [AD]
Enter the following command to add a static route on R1: Enter the following command to add a static route on R2:
ip route 20.20.20.0 255.255.255.0 100.100.100.2 ip route 10.10.10.0 255.255.255.0 100.100.100.1
Routing Lookup Process
When a packet arrives on a router interface, the router examines the IPv4 header, identifies the destination IPv4
address, and proceeds through the router lookup process.
1. The router reads IP addresses in binary, it takes destination IP address from the packet then perform logic AND
with all prefixes in its routing table.
2. If the result is exactly matching the prefix, the router forwards the packet to the next-hop router. If there are
multiply possible prefixes can be used, the longest-match prefix will be selected.
3. The next-hop router repeats the same process – take out destination IP address and perform IP lookup in its
routing table.
4. Sooner or later, there would be one router finds the destination IP address “matches” one of its prefixes and
this prefix is directly connected to it. Now the packet would be handled by Data Link Layer, an ARP request will
be sent out to discovery the final destination host.
The following processes showing Router1 and Router2 perform routing lookup and make routing decision after received
packet destined to 20.20.20.2(Host B):
Convert to binary
1. Destination IP address: 20.20.20.2 00010100.00010100.00010100 .00000010
Convert to binary
Prefix in routing table: 20.20.20.0/24 00010100.00010100.00010100 .00000000 COMPARE THEM
Result = 00010100.00010100.00010100 .00000000 MATCHED!
Since 100.100.100.2 is the next-hop address associated with prefix 20.20.20.0/24, therefore, Router 1 knows Host B can be reached by
forwarding packet to it.
Example: Routing Lookup Process
4. Router 2 receives packets and uses same method to examinant the destination IP address
5. Router 2 finds 20.20.20.0/24 is the matched prefix, and it is directly connected to itself.
Default Route
“In computer networking, the default route is a setting on a computer that defines the packet forwarding rule to use
when no specific route can be determined for a given Internet Protocol (IP) destination address. All packets for
destinations not established in the routing table are sent via the default route.” - Wikipedia
• Some Routing Protocols (namely RIP) use Hop Count to compute distance.
• Less Hop Count path is preferred over more Hop Count Path.
(Not always be, because there are some other criteria can affect path selection – Hop Count is one of them)
In this example, the amount of hops to send packets from Host A to Host B is 3
Traceroute
Traceroute is used to trace back along a path to a target in order to learn the routers that in between the originator
and target. Microsoft traceroute command uses ICMP and the Cisco/Linux traceroute command uses UDP
ICMP Traceroute
UDP Traceroute
Join Us