To route packets, a router needs:
- The destination address
- Source of learning about other networks
- Possible routes to other networks
- A way of maintaining routes
- A method of selecting paths
A router stores the route to destination networks it knows in a routing table. Routing table contains routing information that helps a router in determining the routing path. To show the ip table, use command "show ip route".
For example, the following is the result of the "show ip route" command on a network router running ospf routing protocol.
RouterB#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
O 10.0.0.0/8 [110/65] via 184.108.40.206, 00:00:03, Serial0/0
C 220.127.116.11/8 is directly connected, Serial0/0
C 18.104.22.168/8 is directly connected, FastEthernet0/0
From the above, we can see, routing table provides an ordered list of known network addresses.
For each network address, there are metrics that are used to determine the desirability of the route.
Routing table associations tell a router that a particular destination is either directly connected to the router or that it can be reached via another router (the next-hop router) on the way to the final destination. For example, "C 22.214.171.124/8 is directly connected, Serial0/0 " means 126.96.36.199/8 is directly connected network, while "O 10.0.0.0/8 [110/65] via 188.8.131.52, 00:00:03, Serial0/0" means network 10.0.0.0/8 can be reached via another router at address 184.108.40.206.
In order to pass the CCENT and CCNA exam, we have to understand the following routing table entries:
- Directly connected network (code: C - connected) -- This entry comes from having interfaces attached to network segments. This entry is obviously the most certain; if the interface fails or is administratively shut down, the entry for that network will be removed from the routing table.
- Default route (code: C - connected) -- This is an optional entry that is used when no explicit path to a destination is found in the routing table. This entry can be manually inserted or be populated from a dynamic routing protocol.
- Static routing (code: S - static) -- These routes are entered manually by a system administrator directly into the configuration of a router.
- Dynamic routing (code: I - IGRP, R - RIP, O - OSPF ...) -- These routes are learned by the router, and the information is responsive to changes in the network so that it is constantly being updated.
There are three ways for the router to know an ip address:
- Router knows by default the network addresses of the directly connect networks.
- System admin can statically configure some network addresses with command "ip route 10.0.0.0 255.0.0.0 FastEthernet0/1", where 10.0.0.1 is the destination address, 255.0.0.0 is the subnet mask, FastEthernet0/1 is the interface the packet will exit from the router.
- Router can learned about non-directly connected networks by communicating with its neighbors with various routing protocols.
The routing process have five steps:
- The router receives a packet on one of its interfaces.
- The router de-encapsulates the frame and uses the protocol information of the frame to determine that the network layer packet will pass to the IP process.
- The router checks the destination address in the IP header. Either the packet is destined for the router itself or it needs to be forwarded. If the packet needs to be forwarded, the router searches its routing table to determine where to send the packet.
- If the destination network is on a directly attached network, the router will use the ARP process to obtain the MAC address of the host and forward it to the network segment. If the network is reachable through another router, the router will use the MAC address of the next-hop router and forward the packet out the interface indicated in the routing table. ARP establishes correspondence between network addresses and LAN hardware addresses. A record of each correspondence is kept in the ARP cache. To display the ARP cache, use command "show ip arp" under EXEC mode.
- The outgoing interface process encapsulates the packet into a frame appropriately, send the frame to the media thus sends the packet onto the network segment.
Routing protocol vs Routed protocolA Routed Protocol is a protocol by which actual network packets are routed by the routers. Examples of routed protocol are IP, IPX, and AppleTalk.
A Routing Protocol is only used between routers. Its purpose is to help routers exchange information about the network the routers know about or learned about, so that the routers can build and update routing tables. All IP interior gateway protocols must be specified with a list of associated networks before routing activities can begin. A routing process listens to updates from other routers on these networks and broadcasts its own routing information on those same networks. Examples of routing protocol are Routing Information Protocol (RIP), Open Shortest Path First (OSPF), Internet Gateway Routing Protocol (IGRP), Enhanced Internet Gateway Routing Protocol (Enhanced IGRP or EIGRP), Intermediate System-to-Intermediate System (IS-IS).
The following video introduced the basic concept of Exterior Routing Protocols, Interior Routing Protocols, Autonomous System.
Autonomous System is a group of routers under a autonomous administrative domain.
Interior Gateway Protocol (IGP) : the routing protocols used inside the autonomous system. Example: RIP, OSPF, IGRP, EIGRP
Exterior Gateway Protocol (EGP) or Border Gateway Protocol (BGP): the routing protocols used when one autonomous system need to communicate with another autonomous system.