Introducing the Routing TableThe primary function of a router is to forward a packet toward its destination network, which is the destination IP address of the packet. To do this, a router needs to search the routing information stored in its routing table.
A
routing table is a data file in RAM that is used to store route information about directly connected and remote networks. The routing table contains network/next hop associations. These associations tell a router that a particular destination can be optimally reached by sending the packet to a specific router that represents the "next hop" on the way to the final destination. The next hop association can also be the outgoing or exit interface to the final destination.
The network/exit-interface association can also represent the destination network address of the IP packet. This association occurs on the router's directly connected networks.
A directly connected network is a network that is directly attached to one of the router interfaces. When a router interface is configured with an IP address and subnet mask, the interface becomes a host on that attached network. The network address and subnet mask of the interface, along with the interface type and number, are entered into the routing table as a directly connected network. When a router forwards a packet to a host, such as a web server, that host is on the same network as a router's directly connected network.
A remote network is a network that is not directly connected to the router. In other words, a remote network is a network that can only be reached by sending the packet to another router. Remote networks are added to the routing table using either a dynamic routing protocol or by configuring static routes. Dynamic routes are routes to remote networks that were learned automatically by the router, using a dynamic routing protocol. Static routes are routes to networks that a network administrator manually configured.
Note: The
routing table-with its directly-connected networks, static routes, and d
ynamic routes-will be introduced in the following sections and discussed in even greater detail throughout this course.
The following analogies may help clarify the concept of connected,
static, and
dynamic routes:
Directly Connected Routes - To visit a neighbor, you only have to go down the street on which you already live. This path is similar to a directly-connected route because the "destination" is available directly through your "connected interface," the street.
Static Routes - A train uses the same railroad tracks every time for a specified route. This path is similar to a static route because the path to the destination is always the same.
Dynamic Routes - When driving a car, you can "dynamically" choose a different path based on traffic, weather, or other conditions. This path is similar to a dynamic route because you can choose a new path at many different points on your way to the destination.
The show ip route commandAs shown in the figure the routing table is displayed with the show ip route command. At this point, there have not been any static routes configured nor any dynamic routing protocol enabled. Therefore, the routing table for R1 only shows the router's directly connected networks. For each network listed in the routing table, the following information is included:
C - The information in this column denotes the source of the route information, directly connected network, static route or a dynamic routing protocol. The C represents a directly connected route.
192.168.1.0/24 - This is the network address and subnet mask of the directly connected or remote network. In this example, both entries in the routing table, 192.168.1./24 and 192.168.2.0/24, are directly connected networks.
FastEthernet 0/0 - The information at the end of the route entry represents the exit interface and/or the IP address of the next-hop router. In this example, both FastEthernet 0/0 and Serial0/0/0 are the exit interfaces used to reach these networks.
When the routing table includes a route entry for a remote network, additional information is included, such as the routing metric and the administrative distance. Routing metrics, administrative distance, and the show ip route command are explained in more detail in later chapters.
PCs also have a routing table. In the figure, you can see the route print command output. The command reveals the configured or acquired default gateway, connected, loopback, multicast, and broadcast networks. The output from route print command will not be analyzed during this course. It is shown here to emphasize the point that all IP configured devices should have a routing table.
Adding a Connected Network to the Routing Table
As stated in the previous section, when a router's interface is configured with an IP address and subnet mask, that interface becomes a host on that network. For example, when the FastEthernet 0/0 interface on R1in the figure is configured with the IP address 192.168.1.1 and the subnet mask 255.255.255.0, the FastEthernet 0/0 interface becomes a member of the 192.168.1.0/24 network. Hosts that are attached to the same LAN, like PC1, are also configured with an IP address that belongs to the 192.168.1.0/24 network.
When a PC is configured with a host IP address and subnet mask, the PC uses the subnet mask to determine what network it now belongs to. This is done by the operating system ANDing the host IP address and subnet mask. A router uses the same logic when an interface is configured.
A PC is normally configured with a single host IP address because it only has a single network interface, usually an Ethernet NIC. Routers have multiple interfaces; therefore, each interface must be a member of a different network. In the figure, R1 is a member of two different networks: 192.168.1.0/24 and 192.168.2.0/24. Router R2 is also a member of two networks: 192.168.2.0/24 and 192.168.3.0/24.
After the router's interface is configured and the interface is activated with the no shutdown command, the interface must receive a carrier signal from another device (router, switch, hub, etc.) before the interface state is considered "up." Once the interface is "up," the network of that interface is added to the routing table as a directly connected network.
Before any static or dynamic routing is configured on a router, the router only knows about its own directly connected networks. These are the only networks that are displayed in the routing table until static or dynamic routing is configured. Directly connected networks are of prime importance for routing decisions. Static and dynamic routes cannot exist in the routing table without a router's own directly connected networks. The router cannot send packets out an interface if that interface is not enabled with an IP address and subnet mask, just as a PC cannot send IP packets out its Ethernet interface if that interface is not configured with an IP address and subnet mask.
Note: The process of configuring
router interfaces and adding network address to the r
outing table are discussed in the following chapter.
Related Topic Router