Routing Concepts and Basic Router Configuration
Path Determination
Two primary functions of a router:
Determining the best path using the routing table.
Forwarding packets.
The best path is identified as the longest match in the routing table.
Routing table contains:
Prefix (network address).
Prefix length.
To consider a route a match, the number of matching bits must be at least the number indicated by the subnet mask.
Longest match: The route within the table that has the greatest number of far-left matching bits with the destination IP address of the packet.
Example of IPv4 Address Matching
Destination IPv4 Address: 172.16.0.10 (represented in binary as 10101100.00010000.00000000.00001010)
Routing Table Entries:
Entry 1: 172.16.0.0/12
Entry 2: 172.16.0.0/18
Entry 3: 172.16.0.0/26
The route contains number of matching bits indicated by the subnet mask.
Example of IPv6 Address Matching
Destination: 2001:db8:c000::99/48
Route Entry 1: 2001:db8:c000::/40 (Match of 40 bits)
Route Entry 2: 2001:db8:c000::/48 (Match of 48 bits - longest match)
Route Entry 3: 2001:db8:c000:5555::/64 (Does not match 64 bits)
Routing Table
Directly connected networks: These are added to the routing table when a local interface is assigned an IP address/netmask and is active (up).
Remote networks: Routers learn about these in two ways:
Static routes: Manually added to the routing table.
Dynamic routing protocols: Routing protocols dynamically learn about remote networks.
Default route: A specified next-hop router used when the routing table does not return a specific path (no match) for the destination IP address. Can be set manually or learned from a dynamic routing protocol.
Packet Forwarding
Process:
A data link frame with encapsulated IP packet arrives on the ingress interface.
The router examines the destination IP address in the packet header and checks the routing table (RT).
The router finds the longest matching prefix in RT.
The router re-encapsulates the packet in a data link frame and forwards it to the egress interface; ARP or ICMPv6 ND is used to determine MAC addresses for either the destination connected device or the next-hop router.
If no match is found and there is no default route, the packet is dropped.
Primary responsibility of Packet Forwarding (PF): to encapsulate packets in appropriate data link frames for the Layer 2 type on the egress interface (e.g., PPP or HDLC for a serial link).
Three packet forwarding mechanisms:
Process Switching
Fast Switching
Cisco Express Forwarding (CEF)
Packet Forwarding Mechanisms
Process Switching: An older mechanism where each arriving packet is forwarded to the control plane. The CPU matches the destination address to an entry in the routing table to determine the egress interface. This operation is performed per packet, even if the destination is the same.
Fast Switching: Uses a fast-switching cache to store next-hop information. The CPU searches for a match in the cache. If no match is found, it uses process switching, and the information flow is then stored in the cache. Subsequent packets with the same destination will use the cache information without CPU intervention.
Cisco Express Forwarding (CEF): The most recent Cisco IOS PF mechanism. It builds a Forwarding Information Base (FIB) and an adjacency table. Table entries are change-triggered (when something changes in the topology) instead of packet-triggered (as in fast switching). When the network has converged, the FIB and adjacency table contain all the information that a router needs.
IP Routing Table
The IP routing table is a list of routes to known networks (prefix and length) derived from:
Directly connected networks (C)
Static routes (S)
Dynamic routing protocols (e.g., OSPF, denoted as 'O')
Default route (*)
Address assigned to a router interface (L)
Routing Table principles:
Every router makes its own decisions based on its routing table information.
The information in one router's routing table is not necessarily identical to another router's.
Path routing information doesn't provide return routing information.
Key components in an IP routing table:
Route source: How the route was learned.
Destination network (prefix and length): The remote network address; the prefix length identifies the minimum number of far-left bits that must match between the packet's IP address and the destination network for this route to be used.
Administrative distance: Lower values indicate a more preferred route source; reflects the reliability of a routing protocol.
Metric: Values assigned to reach the remote network. Lower values are preferred.
Next-hop: IP address of the next hop (router).
Route timestamps: Time since the route was learned.
Exit interface: The egress interface to reach the destination.
IP Routing Table Details
Directly connected networks (C): Added when an interface is configured with an IP address and is up. The routing table also contains a local route (L) (prefix /32 for IPv4 and /128 for IPv6, i.e., "all bits must match") for each directly connected network. The local route is used to distinguish packets destined for the interface itself rather than packets to be forwarded.
Static routes (S): Manually configured for remote networks and must be updated manually. Easier to manage in smaller networks. A single default route can be used for any destination beyond the upstream router; this is often used for "stub" networks (i.e., a router with only one neighbor).
Dynamic routing protocols: Automatically share information about reachability and the status of remote networks. They perform several functions, including network discovery and maintaining routing tables.
Default route: Represented as 0.0.0.0/0 (IPv4) or ::/0 (IPv6); can be either static or learned from a dynamic routing protocol.
IPv4 Routing Table Structure & Administrative Distance
IPv4 routing tables are organized using classful addressing (now obsolete), though the lookup process is not classful. Entries are "indented" as "child routes" if they are subnets of classful (A, B, C) addresses. Directly connected networks are always indented (child routes) since the local address of the interface is always entered in the routing table as /32. Child routes include the route source and next-hop address. The classful address of this subnet (parent route) is shown above the route entry, less indented, without a source code.
IPv6 was not classful from the start, hence there is no straightforward routing table structure like in IPv4.
A route entry for a specific network/prefix can appear only once in the routing table. However, it is possible to learn about the same network from multiple routing sources.
General tip: Only one dynamic routing protocol should be implemented on a router!
To determine which source to use and which route to install, the lower the Administrative Distance (AD), the more trustworthy the route source is.
Administrative Distance:
Directly connected: 0
Static route: 1
EIGRP summary route: 5
External BGP: 20
Internal EIGRP: 90
OSPF: 110
IS-IS: 115
RIP: 120
External EIGRP: 170
Internal BGP: 200
Static & Dynamic Routing
Static and dynamic routing are not mutually exclusive; most networks use a combination of both.
Static routes are used when:
Configuring a default route forwarding to an ISP.
Routing to networks outside the routing domain not learned by the dynamic routing protocol.
Explicitly defining a path for a specific network by a network administrator.
Routing between stub networks.
Static routes are suitable for smaller networks with only one path to an outside network and provide security in larger networks for certain traffic types or links to other networks that need more control.
Dynamic routing protocols are suited for any type of network with more than a few routers, offering scalability and adaptability to changes in topology (e.g., by finding better routes).
Dynamic routing is used for:
Networks with more than a few routers.
When changes in network topology require automated determination of a new path.
Scalability, adapting with the network’s growth.
Static & Dynamic Routing Comparison
Feature | Dynamic Routing | Static Routing |
|---|---|---|
Configuration complexity | Independent of network size | Increases with network size |
Topology changes | Automatically adapts to topology changes | Administrator intervention required |
Scalability | Suitable for complex network topologies | Suitable for simple topologies |
Security | Security must be configured | Security is inherent |
Resource Usage | Uses CPU, memory, and link bandwidth | No additional resources needed |
Path Predictability | Route depends on topology and protocol | Explicitly defined by the administrator |
Dynamic Routing has been used since the late 80s, starting with RIP.
New protocols emerged as networks evolved.
Dynamic Routing Protocols
Interior Gateway Protocols (IGP): Used for exchanging routing information within a routing domain administered by a single organization (e.g., an autonomous system, AS).
Examples include RIPv2, EIGRP, OSPFv2, and IS-IS for IPv4, and RIPng, EIGRP for IPv6, OSPFv3, and IS-IS for IPv6.
Exterior Gateway Protocols (EGP): Used for inter-domain routing. BGP is the only protocol used for exchanging routing information between different organizations (i.e., ASes) - used by ISPs to route packets over the Internet.
A routing protocol is a set of processes, algorithms, and messages used to exchange routing information and populate the routing table with the best path. Its functions include:
Discovery of remote networks
Maintaining up-to-date routing information
Choosing the best path to destination networks
Ability to find a new best path when the current path is no longer available
Dynamic Routing Protocols Components
Main components of a dynamic routing protocol:
Data structures: Tables and databases kept in RAM.
Routing protocol messages: Various kinds of messages to discover neighbor routers, exchange routing information, and perform other tasks to learn about the network.
Algorithms: A finite list of steps to determine the best path/route.
The best path is selected based on a "metric" to determine distance; the best path = lowest metric. Different metrics are used by each routing protocol.
Load balancing: When there are two or more paths with equal-cost metrics, both paths can be used equally (equal-cost load balancing), which improves performance. Equal-cost load balancing is implemented automatically by dynamic routing protocols and can also be enabled with static routes when multiple routes to the same network have different next-hops.
Unequal cost load balancing is available only in the EIGRP Routing Protocol.
Examples of Routing Protocols and their metrics:
Routing Information Protocol (RIP): The metric is "hop count." Each router along a path adds a hop, and a maximum of 15 hops is allowed.
Open Shortest Path First (OSPF): The metric is "cost," which is based on the cumulative bandwidth from source to destination. Faster links are assigned lower costs compared to slower (higher cost) links.
Enhanced Interior Gateway Routing Protocol (EIGRP): Calculates a metric based on the slowest bandwidth and delay values. It can also include load and reliability in the metric calculation.
Basic Router Configuration Review
Router> enable
Router# configure terminal
Router(config)# hostname R1
R1(config)# enable secret class
R1(config)# line console 0
R1(config-line)# logging synchronous
R1(config-line)# password cisco
R1(config-line)# login
R1(config-line)# exit
R1(config)# line vty 0 4
R1(config-line)# password cisco
R1(config-line)# login
R1(config-line)# transport input ssh telnet
R1(config-line)# exit
R1(config)# service password-encryption
R1(config)# banner motd # Enter TEXT message. End with a new line and the #
R1(config)# ipv6 unicast-routing
R1(config)# interface gigabitethernet 0/0/0
R1(config-if)# description Link to LAN 1
R1(config-if)# ip address 10.0.1.1 255.255.255.0
R1(config-if)# ipv6 address 2001:db8:acad:1::1/64
R1(config-if)# ipv6 address fe80::1:a link-local
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# interface gigabitethernet 0/0/1
R1(config-if)# description Link to LAN 2
R1(config-if)# ip address 10.0.2.1 255.255.255.0
R1(config-if)# ipv6 address 2001:db8:acad:2::1/64
R1(config-if)# ipv6 address fe80::1:b link-local
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# interface serial 0/1/1
R1(config-if)# description Link to R2
R1(config-if)# ip address 10.0.3.1 255.255.255.0
R1(config-if)# ipv6 address 2001:db8:acad:3::1/64
R1(config-if)# ipv6 address fe80::1:c link-local
R1(config-if)# no shutdown
R1(config-if)# exit
R1# copy running-config startup-config
Basic Router Configuration Review - Show Commands
Common verification commands include the following:
show ip interface brief
show running-config interface interface-type number
show interfaces
show ip interface
show ip route
ping
In each case, replace ip with ipv6 for the IPv6 version of the command
Basic Router Configuration Review - Filters
Filtering commands can be used to display specific sections of output. To enable the filtering command, enter a pipe (|) character after the show command and then enter a filtering parameter and a filtering expression.
The filtering parameters that can be configured after the pipe include:
section - This displays the entire section that starts with the filtering expression.
include - This includes all output lines that match the filtering expression.
exclude - This excludes all output lines that match the filtering expression.
begin - This displays all the output lines from a certain point, starting with the line that matches the filtering expression.
NOTE: Output filters can be used in combination with any show command.