Another role of the network layer is to provide routing of packets between hosts. A host could send a packet to:

Hosts require a local routing table to ensure that network layer packets are directed to the correct destination network. The local table of the host typically contains:

The default gateway is the device that routes traffic from the local network to devices on remote networks. It is often used to connect a local network to the Internet. The network is determined by the IP address and subnet mask combination. If a host is sending a packet to a device that is configured with the same IP network as the host device, the packet is simply forwarded out of the host interface to the destination device directly. A default gateway is not needed in this situation.

However, if the host is sending a packet to a device on a different IP network, then the host must forward the packet to the default gateway, because a host device cannot communicate directly with devices outside of the local network. The default gateway, which is most often a router, maintains routing table entries for all of its directly connected networks, as well as entries of remote networks it may know about. The router is responsible for determining the best path to reach all of those destinations. The default gateway address is the IP address of the router’s network interface connected to the local network.

The figure highlights areas associated with the entries in the local host routing table. In this example, the default gateway address is: 192.168.10.1.