Routing Concepts and Static Routing Notes
Routing Concepts and Static Routing
Functions of a Router
Routers connect multiple networks, each interface residing on a different IP network.
Routers Choose Best Paths
Routers learn about remote networks and construct routing tables using static routes and dynamic routing protocols. They then use these tables to determine the optimal path for sending packets. The packets are encapsulated and forwarded to the interface specified in the routing table.
Best Path Determination
Determining the best path involves evaluating multiple potential routes to the same destination network and selecting the shortest or most optimum one. Routing protocols select the best path based on a metric, which quantifies the distance to a network. The path with the lowest metric is favored. The best path in the routing table is known as the longest match.
IPv4 Longest Match Example
Consider an IPv4 packet destined for the address 172.16.0.10. The router's IPv4 routing table contains three matching entries: 172.16.0.0/12, 172.16.0.0/18, and 172.16.0.0/26. The router will choose the route 172.16.0.0/26 because it has the longest prefix match.
Destination IPv4 Address: 172.16.0.10
Address in Binary: 10101100.00010000.00000000.00001010
Route Entry 1: 172.16.0.0/12
Address in Binary: 10101100.00010000.00000000.00001010
Route Entry 2: 172.16.0.0/18
Address in Binary: 10101100.00010000.00000000.00001010
Route Entry 3: 172.16.0.0/26
Address in Binary: 10101100.00010000.00000000.00001010
Administrative Distance (AD)
When multiple paths to a destination exist, the router selects the path with the lowest Administrative Distance (AD) for installation in the routing table. For example, a static route with an AD of 1 is preferred over an EIGRP-discovered route with an AD of 90. A directly connected route (AD 0) is preferred over a static route (AD 1).
IP Routing Table
An IP routing table is a file stored in RAM containing information such as:
- Local route interfaces: Added upon interface configuration (displayed in IOS 15 or newer).
- Directly connected interfaces: Added when an interface is configured and active.
- Static routes: Added when a route is manually configured with an active exit interface.
- Dynamic routing protocol: Added when protocols like EIGRP or OSPF are implemented and identify networks.
IP Routing Table Route Sources
Routing tables contain routes to known networks, identified by prefixes and prefix lengths, derived from:
- Directly connected networks
- Static routes
- Dynamic routing protocols
Each route is tagged with a code indicating its source:
- L: Address assigned to a router interface.
- C: Directly connected network.
- S: Static route configured to reach a specific network.
- O: Dynamically learned network via OSPF.
- : Candidate for a default route.
Directly Connected Interfaces
A newly deployed router initially has an empty routing table. Configuring and activating a directly connected interface creates two routing table entries:
- Link Local (L)
- Directly Connected (C)
Remote Network Routing Entries
Routing table entries for remote networks include information such as:
- How the network was learned.
- The destination network.
- Administrative distance (trustworthiness).
- Metric (distance to the network).
- Next-hop IP address.
- Time elapsed since discovery.
- Outgoing interface.
Example:
10.1.1.0/24 [90/2170112] via 209.165.200.226, 00:00:05, Serial0/0/0
IP Routing Table Structure
IPv4 routing tables may exhibit a hierarchical structure with parent and child routes. Child routes are subnets of classful networks (A, B, or C) and are indented. Directly connected networks are always child routes with a /32 mask for the local interface address. The parent route represents the classful network address without a source code. IPv6 routing tables have a straightforward structure, with all entries formatted consistently due to the absence of classful addressing.
Show IP route example:
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
O 192.168.2.0/24 [110/65] via 192.168.12.2, 00:00:10, Serial0/0/0
O 192.168.3.0/24 [110/65] via 192.168.12.2, 00:00:10, Serial0/0/0
192.168.12.0/30 is subnetted, 2 subnets
C 192.168.12.0/30 is directly connected, Serial0/0/0
L 192.168.12.1/32 is directly connected, Serial0/0/0
192.168.13.0/24 is variably subnetted, 1 subnets, 1 masks
Static vs. Dynamic Routing
Static Routing:
- Used as a default route to forward packets to a service provider.
- For routes outside the routing domain, not learned by dynamic routing protocols.
- For explicitly defining paths for specific networks.
- For routing between stub networks.
Dynamic Routing:
- In networks with more than a few routers.
- When topology changes require automatic path determination.
- For scalability; automatically learns about new networks as the network grows.
Types of Static Routes
Static routes are not automatically updated and require manual reconfiguration when the network topology changes. Static routes are commonly implemented even when dynamic routing protocols are configured.
Both IPv4 and IPv6 support the following types of static routes:
- Standard static route
- Default static route
- Floating static route
- Summary static route
These routes are configured using the ip route and ipv6 route global configuration commands.
1. Standard Static Route
Useful when connecting to a specific remote (stub) network. It eliminates the need for a dynamic routing protocol when a simple, direct path is sufficient.
2. Default Static Route
A default static route matches all packets (destination address of 0.0.0.0/0 in IPv4). It's useful for stub routers needing a gateway to external networks.
3. Floating Static Route
Provides a backup path with a higher administrative distance than the primary route, ensuring redundancy.
4. Summary Static Route
Represents multiple networks using a single summary address, simplifying routing tables.
For example, networks 172.20.0.0/16, 172.21.0.0/16, 172.22.0.0/16, and 172.23.0.0/16 can be summarized as 172.20.0.0/14
Static Routes Configuration
1. Configure Standard Static Routes
IPv4 Standard Static Routes (ip route Command)
Router(config)#ip route network-address subnet-mask {ip-address | exit-intf}
Parameters:
network-address: Destination network address.subnet-mask: Subnet mask of the remote network.ip-address: Next-hop router's IP address (recursive lookup).exit-intf: Outgoing interface (directly attached static route).
IPv6 Standard Static Routes (ipv6 route Command)
Most parameters are identical to the IPv4 version.
Next-Hop Options
The next hop can be specified using an IP address, an exit interface, or both, leading to three types of routes:
- Option A: Next-hop route (IP address only).
- Option B: Directly connected static route (exit interface only).
- Option C: Fully specified static route (both IP address and exit interface).
Option A: Next-Hop Static Route
When a packet is destined for the 192.168.2.0/24 network, the router performs a recursive lookup, which involves multiple lookups in the routing table before forwarding the packet.
Example (IPv6):
R1(config)#ipv6 route 2001:DB8:ACAD:2::/64 2001:DB8:ACAD:4::2
R1(config)#ipv6 route 2001:DB8:ACAD:5::/64 2001:DB8:ACAD:4::2
R1(config)#ipv6 route 2001:DB8:ACAD:3::/64 2001:DB8:ACAD:4::2
Option B: Directly Connected Static Route
Example:
R1(config)#ip route 172.16.1.0 255.255.255.0 s0/0/0
R1(config)#ip route 192.168.1.0 255.255.255.0 s0/0/0
R1(config)#ip route 192.168.2.0 255.255.255.0 s0/0/0
Example (IPv6):
R1(config)#ipv6 route 2001:DB8:ACAD:2::/64 s0/0/0
R1(config)#ipv6 route 2001:DB8:ACAD:5::/64 s0/0/0
R1(config)#ipv6 route 2001:DB8:ACAD:3::/64 s0/0/0
Option C: Fully Specified Static Route
Both the output interface and the next-hop IP address are specified.
If the IPv6 static route utilizes an IPv6 link-local address as the next-hop, a fully specified static route, including the exit interface, must be configured.
2. Configure IP Default Static Route
Example:
R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.2.2
Example (IPv6):
R1(config)#ipv6 route ::/0 2001:DB8:ACAD:4::2
3. Configure Floating Static Routes
Example:
R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.2.2
R1(config)#ip route 0.0.0.0 0.0.0.0 10.10.10.2 5