contact@embeddedgeeks.com
Embedded World

IP Routing

IP routing is the process of sending packets from a host on one network to another host on a different remote network. This process is usually done by routers. Routers examine the destination IP address of a packet, determine the next-hop address, and forward the packet. Routers use routing tables to determine the next-hop address to which the packet should be forwarded.

Consider the following example of IP routing:

IP routing

Host A wants to communicate with host B, but host B is on another network. Host A is configured to send all packets destined for remote networks to router R1. Router R1 receives the packets, examines the destination IP address and forwards the packet to the outgoing interface associated with the destination network.

Default gateway

A default gateway is a router that hosts use to communicate with other hosts on remote networks. A default gateway is used when a host doesn’t have a route entry for the specific remote network and doesn’t know how to reach that network. Hosts can be configured to send all packets destined to remote networks to the default gateway, which has a route to reach that network.

The following example explains the concept of a default gateway more thoroughly.

Default Gateway

Host A has an IP address of the router R1 configured as the default gateway address. Host A is trying to communicate with host B, a host on another, remote network. Host A looks up in its routing table to check if there is an entry for that destination network. If the entry is not found, the host sends all data to the router R1. Router R1 receives the packets and forwards them to host B.

Routing table

Each router maintains a routing table and stores it in RAM. A routing table is used by routers to determine the path to the destination network. Each routing table consists of the following entries:

  • network destination and subnet mask – specifies a range of IP addresses.
  • remote router – IP address of the router used to reach that network.
  • outgoing interface – the outgoing interface the packet should go out to reach the destination network.

There are three different methods for populating a routing table:

  • directly connected subnets
  • using static routing
  • using dynamic routing

Consider the following example. Host A wants to communicate with host B, but host B is on another network. Host A is configured to send all packets destined for remote networks to the router. The router receives the packets, checks the routing table to see if it has an entry for the destination address. If it does, the router forwards the packet out the appropriate interface port. If the router doesn’t find the entry, it discards the packet.


We can use the show IP route command from the enabled mode to display the router’s routing table.

show ip route command

As you can see from the output above, this router has two directly connected routes to the subnets 10.0.0.0/8 and 192.168.0.0/24. The character C in the routing table indicates that a route is a directly connected route. So when host A sends the packet to host B, the router will look up into its routing table and find the route to the 10.0.0.0/8 network on which host B resides. The router will then use that route to route packets received from host A to host B.