3.1.a Routing Protocol Codes Overview
Using the command #show ip route, one of the very first components of the routing table that you will see are the routing table codes which are located at the be beginning of routing table entry. Cisco did a good job of interpreting the codes in the table to let us know what each code means. Remember, a routing table consists of entries to networks that are statically configured by the administrator or dynamically learned through the routing protocols. There about 24 codes in the routing table. See diagram below;
3.1.b Network Prefix (or Network Portion)
The network prefix determines the number of IP addresses within a particular host section of IP addresses. A network prefix is an aggregation of IP addresses. In CIDR notation, IP addresses are written as a prefix, and a suffix is attached to indicate how many bits are in the entire address. The suffix is set apart from the prefix with a slash mark (/). For instance, in the CIDR notation 192.0.1.0/24, the prefix is 192.0.1.0, and the total number of bits in the address is 24.
128.208.0.0/24 will tell us that the first 24 bits is the “Network” part of the IP address and that also helps me know the subnet mask which in this case will be 255.255.255.0, and the remaining 8 bits will be for the host in the given Network. Also, worthy of note is that 192.0.1.0 and 128.208.0.0 are both the lowest IP address that are available in these given networks and the lowest number is never used, it always defines the network, therefore, a prefix is the network address part in the CIDR notation.
For example, 10.10.1.16/32 is an address prefix with 32 bits, which is the highest number of bits allowed in IPv4.
A prefix-length is just the shorthand way to express a subnet mask using CIDR notation. If the subnet mask is 255.255.255.0 then the prefix-length is /24. The prefix length can be in the range 0–32 for IPv4 addresses and 0–128 for IPv6 addresses.
3.1.c Network Mask
A Netmask is a 32-bit “mask” used to divide an IP address into subnets and specifies the network’s available hosts. In a netmask, the 0 and 255 are always assigned and cannot be used. For instance: in this mask 255.255.225.0, the “0” is the assigned network address while for this mask 255.255.255.255, the “255” is the assigned broadcast address. 255.255.255.0 255.255.255.255. Network mask defines how large a network is.
IP | Netmask | Description |
192.168.55.120 | 255.255.255.255 | Only applies to 192.168.55.120 |
192.168.75.0 | 255.255.255.0 | Applies to this IP range 92.168.55.0 – 192.168.75.255 |
192.168.55.240 | 255.255.255.240 | 192.168.55.240 – 192.168.55.255 |
192.168.0.0 | 255.255.0.0 | 192.168.0.0 – 192.168.255.255 |
While subnet masks are mostly used in network configurations, network masks (netmask) often refer to classes of IP addresses. A netmask is a 32-bit value that divides IP addresses into sections, precisely 4 sections/octets with each section having 8 bits, making a total of 32 bits. They are used to define a range of IP addresses that ISPs or other organizations are licensed to or can use. Remember we talked earlier about the classes of IP addresses, namely
- Class A: 255.0.0.0
Class A defines a range of IP addresses in which the first octet is 255 and the other remaining 3 octets are empty with o, meaning the last 3 octets can each contain a number from 0 to 255.
- Class B: 255.255.0.0
Class B defines a range of IP addresses in which the first two octets are 255 and the other remaining 2 octets are empty with o, meaning the last 2 octets can each contain a number from 0 to 255.
- Class C: 255.255.255.0
Class C defines a range of IP addresses in which the first three octets are 255 and the last remaining octet is empty with o, meaning the last octet can contain a number from 0 to 255.
Looking at class C for example, 255.255.255.0, the binary representation of that may also be written as (11111111.11111111.11111111.00000000), 4 sections of 8 bits each which make up the netmask. The sections with all 1s are pre-set and so can’t be changed, while the section with all 0s allows any number between 0 and 255.
Examples
What is the prefix, prefix-length and the network mask for the following; 172.16.2.0/24
Prefix is 172.16.2.0, prefix length is 24 and network mask is 255.25.255.0
What is the prefix, prefix-length and the network mask for the following; 172.16.2.1/32
Prefix is 172.16.2.1, prefix length is 32 and network mask is 255.25.255.255
For IPV4, this is the most specific prefix-length possible and being more specific than the /24 shown above, this route will be preferred for this specific IP address
NOTE: In prefix notation, network mask is listed in /x (/16, /24, /28) and in non-prefix notation, the network mask is listed as 255.0.0.0, 255.255.0.0 and so on.
3.1.d Next hop
In the routing table, Next hop is not seen anywhere there but it is denoted by the word “via”. Next hop is a routing term that refers to the next closest router a packet can go through. The next hop is among the series of routers that are connected in a network and is the next possible destination for a data packet.
The next hop ip address follows the word via, so when you see this in the table, 172.16.1.0 [120/1] via 10.10.10.3 00:00:19. FastEthernet 0/0. So, in this diagram, the Next hop is the -via 10.0.0.2 connected on serial2/0
3.1.e Administrative Distance (First criterion)
Administrative distance is the first criterion that a router uses in determining which routing protocol to use if two or more protocols provide route information for the same destination. It is a value routers use to select the best path when there are two or more different routes to the same destination from two different routing protocols. Administrative Distance counts the reliability or trustworthiness of a routing protocol. When different routing sources indicates that they know how to get to a destination network/prefix, the router breaks the ties by using the AD. between routing resources. Administrative distance has only local significance, and is not advertised in routing updates. Note: The smaller the administrative distance value, the more reliable the protocol.
Cisco ranks the trustworthiness of the various routing resources from lower score being better to higher. Meaning a lower AD is preferred to a higher AD and directly connected prefix is by far the most believable. The maximum configurable AD for a route is 255 and this makes the route unusable because the router will not believe the source of the route and the route will not be included in the table.
For example, if a router receives a route to a network from both Open Shortest Path First (OSPF) with default AD of 110 and Interior Gateway Routing Protocol (IGRP) with default AD of 100, the router will choose IGRP because IGRP is more reliable based on the lower AD. This means the router adds the IGRP version of the route to the routing table. If the link of the IGRP-derived information goes down due to a power outage for example, the OSPF-derived information will be used as the next option until the IGRP-derived information reappears.
3.1.f Routing Protocol Metric
Metrics are cost values used by routers to determine the best path to a destination network. Several factors help dynamic routing protocols like OSPF, RIP and other decide which is the preferred or shortest path to a destination. Metrics are the network variables used in deciding what path is preferred. For some routing protocols these metrics are static and may not be changed.
For other routing protocols these values may be assigned by a network administrator. The most common metric values are hop, bandwidth, delay, reliability, load, and cost. Rip for example uses hop count, which speaks about the number of routers to cross to reach the destination, OSPF uses bandwidth, lower values indicate preferred routes. So in this RIP learned route, denoted by “R” from the routing codes,
Metric -here is (/1) in the entry “120 /1” in the table, meaning, 1 hop count. Routes are chosen and built in the routing table based on the routing protocol’s administrative distance. The routes learned from the routing protocol with the lowest administrative distance are installed in the routing table.
If there are multiple paths to the same destination from a single routing protocol, then the multiple paths would have the same administrative distance and the best path is selected based on the metrics. Metrics are values associated with specific routes, ranking them from most preferred to least preferred.
The parameters used to determine the metrics differ for different routing protocols. The path with the lowest metric is selected as the optimal path and installed in the routing table. If there are multiple paths to the same destination with equal metrics, load balancing is done on these equal cost paths.
3.1.g Gateway of Last resort
Gateway of Last Resort (a.k.a Default Routes) is used in forwarding packets whose destination address does not match any route in the routing table or not explicitly listed in the routing table. In IPv4, the CIDR notation for a default route is 0.0.0.0 0.0.0.0 is a non-routable address used to designate an invalid, unknown or non-applicable target. Therefore, In the context of a route entry, it usually means the default route. if there is no default gateway configured, then a packet is dropped if no other route is found for it. Useful when dealing with a network with a single exit point.
Gateway of last resort can be dynamically learned or can be set by suing three different commands;
- ip default-gateway
- ip default-network and
- ip route 0.0.0.0 0.0.0.0
The way in which routing protocols propagate the default route information varies for each protocol. Notice our routing table below indicates that, there is no Gateway of Last Resort Set. This means that there is no default route 0.0.0.0 0.0.0.0 setup that will allow the router to send traffics somewhere if it does not have a specific route or prefix entry for that destination ip address.