What is a Routing table and show ip route command?
We, as network engineers, frequently use the show ip route command to examine and manage the routing table on a router. In this article, we will explain what is a routing table, the types of routes it contains, the ip routing table example, and the show ip route command in detail.
I would suggest reading my article on routing first. You can also read about the OSI model and TCP/IP model to get a good grasp of the overall networking concepts.
What is a routing table, and why is it used?
A routing table is a data table inside routers that stores and retrieves information about routes to specific IP destinations. The routes are then used to send packets across network links to the correct destination.
In computer networking, a route is a set of instructions that specify how routers should forward IP data packets from one network device to another. Routers and switches use route tables to determine how to forward data packets through a network.
The data in a routing table is used to find the most direct route for a packet to take to its final destination. The source and destination IP addresses are included in every packet. When a packet is received, the network device looks inside the IP packet and compares it to the entries in the routing table. The specific entry that provides the best match for the destination is used to determine where to send the packet next.
Let us look at the fields of a layer 3 IPv4 packet.
How does the IP routing table work?
When an IP packet reaches a router, the router opens it and checks the destination IP address to see if it needs to be sent to another network.
Then, the router checks the Routing Information Base (RIB) to see if it has a route to the destination network. If a matching route is found then the packet is modified and sent through the correct interface. If the routing table doesn’t find a match, the packet is sent to the default gateway if one is configured. And if there is no default gateway configured, then the IP packet will be dropped.
The routing table on a Cisco router, or any other vendor’s router, is referred to as the Route Information Base (RIB). You can view RIB information in a formatted form by typing the show ip route command.
Below is the Route Selection process to install a route in the RIB:-
First, it checks the longest match/prefix available in the RIB. So, for example, if It has two routes from two routers, 192.168.1.0/24 and 192.168.1.0/27, it will always choose 192.168.1.0/27.
The second is Administrative distance (AD), and the lowest AD is always preferred. For example, If a router has two routes with the same prefix (192.168.100.0/24), one from RIP and one from OSPF. Then OSPF will be preferred due to lower AD.
The third rule is the lowest metric. For example, if a router has two routes with the same prefix (192.168.100/024), both are learned from OSPF. Then the router will prefer the device with the lowest metric.
There are some exceptions to the above rules:-
- If two protocols have the same AD (and one has been modified) and the router must determine which one to install in the RIB, it will use the default AD as the tie-breaker.
- A router cannot install the two best routes from different protocols in the routing information base (RIB).
- If a tie exists within OSPF routes, a router will select the best route in the following order, O> O*IA> E1> E2.
- The BGP best-path selection process will be used if there is a tie within BGP routes.
Each routing protocol maintains a unique database of routes.
EIGRP has the topology tables, whereas OSPF has the OSPF database. It’s up to each protocol to decide which routes to keep in its database. Routing protocols calculate the best route based on their own metrics, which can vary widely. The routing protocol used to learn the route determines the metric value. As a result, a single network link can have vastly different metrics depending on the protocol it is connected to. For example, routers can simultaneously describe the same path with a metric of 5 in RIP, 100 in OSPF, and 206175 in EIGRP.
Below is the table of routing protocols and their Administrative Distance (AD).
Route type | Administrative distance |
Connected Interface | 0 |
Static Route | 1 |
EIGRP Summary Route | 5 |
External Border Gateway Protocol (eBGP) | 20 |
Internal EIGRP | 90 |
IGRP | 100 |
OSPF | 110 |
IS-IS | 115 |
RIP | 120 |
External Gateway Protocol EGP | 140 |
On-Demand Routing | 160 |
External EIGRP | 170 |
Internal BGP (iBGP) | 200 |
Unknown | 255 |
How to maintain a Routing Table?
Routing tables can either be maintained manually by static routing or dynamically by using routing protocols, like OSPF, IS-IS, EIGRP, etc.
When a device is configured for static routing, the devices require manual changes from a network administrator to update their routing tables. In contrast, once the initial configuration is completed, dynamic routing automatically allows devices to build and maintain their routing tables.
Dynamic routing uses routing protocols to exchange information about the surrounding network topology. In addition, Dynamic routing tables allow networked devices to efficiently respond to changes in network conditions, such as device failures and congestion. By constantly monitoring the network, devices can avoid potential problems and maintain optimal performance.
IP Routing table example and Show ip route command cisco explained
Each routing table entry has the following entries:-
- Network ID:
- It is the destination network ID corresponding to the destination route.
- Subnet Mask or CIDR:
- The subnet mask or CIDR is used to match a destination IP address to the network ID.
- Next Hop:
- The neighboring device’s IP address is where the router will forward the packet next.
- Outgoing Interface:
- The outgoing network interface of the local device is used to forward the packet to the next hop or final destination.
- Administrative Distance or AD:
- AD is used to choose a better route among two or more similar routes; lower AD is preferred.
- Metric:
- Metric is used mostly by Dynamic routing protocols. It assigns a cost to each available route so that router can choose the most cost-effective path. Lower cost is preferred.
Type of IP Routes
If you are not running any dynamic routing protocol, the routing table contains six types of routes. These routes are visible with the ” show ip route” command.
Host route
A host route is a route that points directly to a host. That is, the route does not connect to a network. The subnet mask for host routes is 255.255.255.255, and the prefix length is /32.
Subnet
Subnets are portions of larger networks. It is used to define the subnet’s size. A subnet is 192.168.1.0/24 (255.255.255.0).
Summary (group of subnets)
A summary route is an individual route that references multiple subnets. For example, if subnets with longer masks (such as 192.168.1.0/24) existed, 192.168.0.0/16 (255.255.0.0) would be a summary.
Major network
A major network is a classful network with its native subnet mask, for example, 192.168.0.0/16 or 192.168.0.0 255.255.0.0
Supernet (group of contiguous major networks)
A supernet is a single route that references a group of major networks. For example, 192.168.0.0/16 is a supernet that groups 192.168.0.0/17 and 192.168.128.0/17.
Default route
A default route often referred to as the gateway of last resort is shown as 0.0.0.0/0. If the destination IP address in a packet does not match any other route, this default route is used in those cases. Often devices connected to the Internet have a default route pointed towards an ISP router.
Conclusion
In this blog post, you have learned about the routing tables, why we use them, and their types. Finally, we have provided details of all essential fields of the show ip route command. Thank you for reading!
Frequently Asked Questions
What is in a routing table?
A routing table is a table filled with data that stores the routes to particular network destinations and their administrative distance, metrics, etc., associated with those routes. The routing table is consulted every time a router needs to forward data packets to another router on the network. The most basic form of a routing table includes:
- Network ID
- Subnet mask or CIDR
- Next Hop
- Outgoing Interface
- Administrative Distance or AD
- Metric
- How to Get Your Home Wired With Network Cables? - December 19, 2024
- Wi-Fi 7 or 802.11be: A Quantum Leap in Wireless Networking Technology - December 11, 2024
- NETGEAR Nighthawk (RAX54S) WiFi 6 Router Review - August 24, 2024