“Packet Routing” is the primary operation in TCP/IP networks that establishes communication from a source device located on one network to a destination device located on another network.
Within the OSI model, routing is a Layer 3 process which groups Internet Protocol (IP) data into Packets that are put inside of Frames (Layer 2 in the OSI).
These Frames are forwarded between devices, which operate at Layer 3 called Routers. You need to know that Frames work at Layer 2 whereas Packets work at Layer 3. Frames contain Packets inside them.
Brief Intro to Routing
When a Frame containing a Packet is sent from a Router it is marked with a source IP address and a destination IP address.
The Router knows which direction to send the Packet (and hence the Frame) by looking up the destination IP address in a table called a Routing table.
This table is a sort of directory which stores all the addresses or routes that are known to the Router.
If a destination address is not known to the Router, it is forwarded out of the interface which is configured as a default route. If no default route has been configured, then the Frames are dropped.
Network routing is often compared to the analogy of the Postal Service and parcels. In order for a parcel to be delivered to a recipient the post office will need to know the street address and house number and postal code to send the parcel to the correct address. This is similar to an IP address.
The post office then looks through its list of Postal codes to see which town’s sorting office the parcel needs to be sent to.
This is similar to the Router checking its routing table. If the post office does not match a postcode, then the parcel is returned to the sender.
In the Routers case the Frame containing the data packet is dropped or forwarded out of the default interface.
Routing on Cisco Routers
The exact method that a Cisco Router uses to decide whether or not to process a Frame is as follows:
- The data-link frame is arriving at the Router and goes through a Frame Check Sequence (FCS) which checks for any errors during the transmission from the previous device. If there are no errors the frame is moved to the next stage of processing.
- The next stage is for the packet to be de-encapsulated from inside the data-link frame. This is like removing the letter from an envelope.
- Next the Router checks the routing table to decide where to send the packet. If there is a Route which matches the destination IP address in the packet, then the Router identifies which outbound interface the packet needs to be sent through. This will usually be to the next hop router.
- The packet is then encapsulated inside another frame which is suitable for transporting the packet out of the outgoing interface. The outgoing interface could be a Serial link or Ethernet and would require a different header and trailer to be added to the packet depending on the protocol that is used for the transportation.
- The final stage is to transmit the frame from out of the identified interface as listed by the matched IP address in the routing table.
It is not possible to send a packet directly from a source router to a destination router in one go, the route taken to the destination may pass through many different Routers belonging to many different networks and each router that the packet passes through is known as a ‘hop’.
Routing Table
When a Router first boots up, its routing table is empty. There are three methods that the Router uses to add IPv4 addresses to its routing table.
- The first method looks for any directly connected These are IP addresses that are directly configured to an interface of the Router itself. These are known as “directly connected routes”.
- The second method is by the Network Administrator manually adding the routes to the Routing table. This is known as “static routes”.
- The third and final method is for the Router to dynamically learn about available routes through advertisements which are sent by dynamic routing protocols. These are known as “dynamic routes”.
What is Static Routing
Static Routing is the method of manually adding Routes to a Routers’ Routing table. There are 4 different types of Static routes which are network routes, host routes, default routes and floating static routes.
When configuring a Static Route, it is important to remember that the route must be configured in both directions from the source to destination and from the destination back to the source.
If a route is configured only one way, the traffic will be received by the destination, but no reply will be sent in return.
Network Static Routes
These are routes which are manually set by the Network Administrator and usually point to the IP address of the next hop Router and reference an entire subnet or Class A, B or C network.
To set a static network route on a Cisco Router the following command is used:
ip route <destination network><Subnet Mask><Gateway IP address or exit interface name >
Example
ip route 172.16.2.0 255.255.255.0 172.16.5.2
or
ip route 172.16.2.0 255.255.255.0 s0/0/0
The above command tells the router that in order to reach destination network “172.16.2.0/24” then packets must be sent to gateway with IP 172.16.5.2 (or via exit interface s0/0/0).
Host Static Routes
This type of Static Route points towards a single Host address rather than an entire Network Subnet.
When matching to a single host address rather than an entire subnet the Subnet Mask used is 255.255.255.255 which will allow the Routers logic to match the entire address.
On a Cisco Router a Host Route is configured as follows:
ip route <destination Host IP><Full Subnet Mask><Gateway IP address or exit interface name >
Example
ip route 172.16.2.6 255.255.255.255 s0/1/1
The above tells the router that in order to reach the single host 172.16.2.6, the packet must exit via interface s0/1/1.
Default Static Routes
If a packet is received with a destination IP address that is not found in a Router’s Routing table, the default action for the Router is to drop the packet.
A default route tells the Router not to drop the packet but to forward any unknown destinations out of a particular interface.
This is configured on a Cisco router with the following command:
ip route<All Zero Destination><All Zero Subnet Mask><Gateway IP address or exit interface name >
Example
ip route 0.0.0.0 0.0.0.0 s0/0/1
or
ip route 0.0.0.0 0.0.0.0 10.10.0.10
Floating Static Routes
When there is more than one Route available in the routing table to a destination network the Router chooses the best of the Routes to take by comparing metrics.
These metrics determine which route is fastest and more reliable. From these metrics the route is given an administrative distance (AD) with the lowest AD being the preferred Route.
By default, a Static assigned Route has an AD of 1. A Route learned by a dynamic routing protocol such as OSPF will have a higher default AD, (110 for OSPF) so a Static Route would be preferred by the Router even if the OSPF learned route is faster than the Static route.
To allow the OSPF route to be used as the Primary route and the Static Route to be used as a backup route, the AD of the Routes can be manually adjusted.
If the Static Route was configured with the AD of 130, the OSPF route would be preferred with the default AD of 110.
If the OSPF link was to fail, then the Static Route would be used instead. To manually configure the AD on a Cisco Router:
ip route <destination network><Subnet Mask><Gateway IP address or exit interface name ><AD>
Example
ip route 172.16.2.0 255.255.255.0 172.16.5.2 130
The above sets the Administrative Distance (AD) of the static route to 130.
How to View the Routing Table
To view the entire Routing table in a Cisco Router the command show ip route is used.
To view all the Static Routes that are configured on a Cisco Router the command show ip route static is used.
What is Dynamic Routing
Protocols have been developed to allow Routers to share the contents of their Routing tables with each other.
This allows the Router to learn about all the available Routes within a network or Autonomous System (a group of networks in the same administrative domain) automatically from their neighbouring Routers.
Routing Protocols that learn all the existing routes within a network or Autonomous System are known as Interior Routing Protocols.
Routing Protocols that learn routes that connect to different Autonomous Systems are known as Exterior Routing Protocols.
Interior, Exterior, Link State, and Distance Vector Protocols
Interior – RIPv2, EIGRP, OSPF, iBGP, IS-IS etc
Exterior – eBGP
Each Router sends packets containing the contents of their Routing tables to their neighbouring Router, these are called Routing Advertisements.
How often these Routing advertisements are sent depends on the type of Dynamic Routing Protocol that is used.
Protocols such as RIPv2 and EIGRP are called Distance Vector Protocols and they determine if a route is up and usable by regularly sending keepalives to their neighbouring Routers.
If a keepalive is not seen after a pre-configured amount of time then the route is removed from the Routing table and a Routing Advertisement containing a copy of the entire routing table is sent to all neighbours.
Protocols such as OSPF and IS-IS are known as link state protocols. These protocols keep a link state database as well as a Routing table.
When a link goes down on a Router that Router will send a Link State Advertisement to its neighbours telling them that just that link is down.
They don’t send a copy of their whole Routing table in the advertisement which saves on bandwidth and is more efficient.
To see which Routing Protocols are being used on a Cisco Router the command show ip protocols is used.
Static Routing Vs Dynamic Routing
Static Routing is a manual process and all routes in the Routing table of all the connecting Routers between Source and Destination are manually configured by the Network Administrator.
Static Routing is often used on point-to-point links to Stub Routers or as a backup link to routes provided by a dynamic routing protocol.
Dynamic Routing is achieved by configuring a Routing Protocol such as RIPv2 or OSPF on each Router and new routes or broken routes are automatically shared between the Routers who dynamically update their Routing tables without requiring intervention from the Network Administrator.
The following table shows the main differences between Static Vs Dynamic Routing:
Static Routing | Dynamic Routing |
Configured manually by the administrator | Automatically created by a Routing Protocol. |
Easy to configure. | More complex to configure (many configuration options, you must know what you are doing). |
Best for small networks | Best for medium to large networks. |
Provide limited path redundance and failover. | Provide very good path redundance, load balancing and failover. |
Routes do not react on network changes. | Routes change and react with network changes (e.g when a link goes down). |
Low resource usage on Router device. | High resource usage on Router device (must have enough memory to hold the routing table). |
Does not use complex algorithms. | Dynamic routing uses complex routing algorithms. |
Better network security. | Lower network security (unless proper security is implemented, such as routing authentication etc). |
Great interoperability between router vendors. | Routing interoperability between vendors is challenging. |
Advantages of Static Routing
- Static Routes never change so the routes taken by traffic are predictable.
- Static Routes are more secure than dynamic routes because Static Routes cannot be altered by injecting false routes into the Routing table. Routes are also not advertised over the network so Routing tables cannot be captured for reconnaissance purposes.
- Static Routes consume less bandwidth because there are no Routing Advertisements or Link State Advertisements being sent between Routers that have only been configured with Static Routes.
- Less CPU cycles are used by Routers that are only configured with static routing.
Advantages of Dynamic Routing
- Reduces the amount of work that a Network Administrator needs to carry out as routes are automatically added to the Routing Table.
- If a Router fails or there is a link break, there is no interruption to service as the Routing Table will automatically be updated and the broken route is removed allowing the Router to choose an alternative path.
- A dynamic Routing Protocol can provide also load balancing and redundancy.
- In depth knowledge of the network topology is not required which makes it easier to manage routes within large networks whereas manually assigning routes would be inefficient and challenging.
IPv6 Routing
Due to the gradual exhaustion of the number of available addresses in an IPv4 network, IPv6 addressing is now often used.
The same principles for Static Routing and Dynamic Routing apply to IPv6 as IPv4 except more up to date versions of the Dynamic Routing Protocols are used and the commands for configuring Static Routes are slightly different.
IPV6 Routing is not enabled by default on a Cisco Router. The command ipv6 unicast-routing needs to be applied to enable IPv6 routing. To configure an IPv6 Static Route on a Cisco Router:
ipv6 route <destination IPv6 address plus Subnet><exit interface or gateway IP>
ipv6 route 2001:db8:1111:1::/64 s0/0/1
Related Posts
- Discussion and Explanation of OSPF Graceful Restart and Shutdown
- Explanation and Configuration of OSPF MD5 Authentication on Cisco Networks
- Explanation of BGP Neighbor Adjacency States on Cisco Devices
- How to Configure Static Routing on Cisco IOS Routers (Examples)
- Comparison of BGP Confederations vs Route Reflectors