# Day 11: Routing Fundamentals

# Routing Fundamentals &amp; Static Routing

## Overview

What is Routing?

Routing is the process that routers use to determine the path that IP packets should take over a network to reach their destination.

Core Concept:

- Routers forward packets between different networks (across network boundaries)
- Switches forward frames within the same LAN (within a network)
- A router reads the destination IP address and determines where to send the packet next

Key Difference from Switching:

Switches (Layer 2):

\- Examine destination MAC address

\- Forward within the same LAN

\- Fast forwarding to connected devices

#   


Routers (Layer 3):

\- Examine destination IP address

\- Forward between different networks

\- Use routing tables to determine best path

#   


---

## Routing Tables

### What is a Routing Table?

A routing table is a database of routes that tells the router where to send packets destined for specific networks or IP addresses.

Stored on: Every router in the network

Content: Network destinations and how to reach them

### Route Components

Each route entry contains:

Destination Network → Next-Hop Router (or directly connected)

#   


Example:

Destination: 192.168.2.0/24 → Send to next-hop router: 10.0.0.2

Destination: 10.1.1.0/24 → Send directly out interface G0/1

Destination: 172.16.0.0/16 → Send to next-hop router: 10.0.0.3

#   


### Route Types

When a router receives a packet, it can take one of three actions:

1\. Forward to Next-Hop Router

Route: "To reach 192.168.1.0/24, send to router 10.0.0.2"

#   


Router receives packet destined for 192.168.1.50

↓

Looks in routing table: "I have a route to 192.168.1.0/24"

↓

Action: Forward packet to 10.0.0.2 (next-hop IP)

↓

Router 10.0.0.2 receives and continues forwarding

#   


2\. Forward Directly to Destination (Directly Connected)

Route: "192.168.1.0/24 is directly connected to my G0/1 interface"

#   


Router receives packet destined for 192.168.1.100

↓

Looks in routing table: "192.168.1.0/24 is on my G0/1 interface"

↓

Action: Send packet directly out G0/1 to destination

#   


3\. Receive for Itself

Route: "10.0.0.0/24 is my own interface"

#   


Router receives packet destined for 10.0.0.1 (its own IP)

↓

Looks in routing table: "This is MY IP address"

↓

Action: Don't forward, receive packet and process it

#   


### Viewing the Routing Table

Router# show ip route

#   


This displays all routes the router knows about.

Output includes:

Gateway of last resort is not set

#   


 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C 10.0.0.0/24 is directly connected, GigabitEthernet0/0

L 10.0.0.1/32 is directly connected, GigabitEthernet0/0

 192.168.0.0/16 is variably subnetted, 2 subnets, 2 masks

C 192.168.1.0/24 is directly connected, GigabitEthernet0/1

L 192.168.1.254/32 is directly connected, GigabitEthernet0/1

S 192.168.2.0/24 \[1/0\] via 10.0.0.2

#   


Legend:

C = Connected (directly connected)

L = Local (router's own IP)

S = Static (manually configured)

D = Dynamic (learned from routing protocol)

R = RIP, O = OSPF, B = BGP (dynamic protocols)

#   


---

## Routing Methods

There are two main ways routers learn routes and populate their routing tables:

### 1. Static Routing

What it is:

- Network engineer/administrator manually configures routes
- Routes do NOT change automatically
- Engineer must manually update routes if network changes

Advantages:

- Simple to understand and implement
- No overhead (no routing protocol traffic)
- Secure (no routing information shared automatically)
- Good for small networks

Disadvantages:

- Must manually configure every route
- Doesn't adapt if network fails or changes
- Not scalable for large networks
- Time-consuming to maintain

When to use:

- Small networks (&lt; 10 routers)
- Point-to-point links (few destinations)
- Labs and testing
- When security requires manual control

### 2. Dynamic Routing

What it is:

- Routers automatically share routing information with each other
- Routers learn and update routes automatically
- Routes adapt when network conditions change

Advantages:

- Automatic route discovery and updates
- Adapts to network failures
- Scalable for large networks
- Less manual configuration
- Load balancing across multiple paths

Disadvantages:

- More complex to configure and understand
- Uses network bandwidth and CPU (routing protocol overhead)
- Slower initial convergence
- Security concerns (routing information shared)

Common Dynamic Routing Protocols:

<div align="left" dir="ltr" id="bkmrk-protocol-type-purpos"><table><colgroup><col width="324"></col><col width="109"></col><col width="191"></col></colgroup><tbody><tr><td>Protocol

</td><td>Type

</td><td>Purpose

</td></tr><tr><td>RIP (Routing Information Protocol)

</td><td>Distance Vector

</td><td>Simple, outdated

</td></tr><tr><td>OSPF (Open Shortest Path First)

</td><td>Link State

</td><td>Industry standard, widely used

</td></tr><tr><td>EIGRP (Enhanced Interior Gateway Routing Protocol)

</td><td>Hybrid

</td><td>Cisco proprietary, powerful

</td></tr><tr><td>BGP (Border Gateway Protocol)

</td><td>Path Vector

</td><td>Internet routing

</td></tr></tbody></table>

</div>When to use:

- Medium to large networks
- Complex topologies
- Multiple paths to destinations
- Networks with redundancy
- When automatic failover is needed

---

## WANs (Wide Area Networks)

### What is a WAN?

A Wide Area Network (WAN) is a network that extends over a large geographic area — typically connecting multiple locations (cities, countries, or across the Internet).

Characteristics:

- Connects different LANs together
- Uses routers to connect
- Often uses leased lines or Internet as backbone
- Lower bandwidth and higher latency than LANs
- Can span great distances

Example WAN Architecture:

 \[LAN A\]

 |

 Router A ←→ Router B ← WAN Link (Internet or Leased Line)

 | |

 \[LAN B\] \[LAN C\]

#   


Routers A and B are connected via WAN

Each router serves its local LAN

Users in LAN A can reach LAN B/C through routers

#   


### LAN vs WAN

<div align="left" dir="ltr" id="bkmrk-feature-lan-wan-size"><table><colgroup><col width="91"></col><col width="188"></col><col width="191"></col></colgroup><tbody><tr><td>Feature

</td><td>LAN

</td><td>WAN

</td></tr><tr><td>Size

</td><td>Single building/floor

</td><td>Multiple locations

</td></tr><tr><td>Speed

</td><td>Fast (100 Mbps - 10 Gbps)

</td><td>Slower (1-100 Mbps)

</td></tr><tr><td>Devices

</td><td>Switches, local routers

</td><td>Routers, modems, firewalls

</td></tr><tr><td>Latency

</td><td>Low (&lt; 1ms)

</td><td>Higher (10-100+ ms)

</td></tr><tr><td>Ownership

</td><td>Single organization

</td><td>Often shared/rented

</td></tr><tr><td>Cost

</td><td>Lower per Mbps

</td><td>Higher per Mbps

</td></tr></tbody></table>

</div>---

## Static Routing Configuration

### Basic Static Route Syntax

Router(config)# ip route &lt;destination-network&gt; &lt;subnet-mask&gt; &lt;next-hop-ip&gt;

#   


Components:

- destination-network — The network you want to reach (e.g., 192.168.2.0)
- subnet-mask — Netmask of that network (e.g., 255.255.255.0)
- next-hop-ip — IP address of the next router (e.g., 10.0.0.2)

### Example 1: Basic Static Route

Scenario:

- Router A at 10.0.0.1 needs to reach network 192.168.2.0/24
- Router B (next-hop) is at 10.0.0.2 on a shared link with Router A

Configuration:

RouterA(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2

#   


Translation: "To reach 192.168.2.0/24, send packets to my neighbor at 10.0.0.2"

Result in routing table:

S 192.168.2.0/24 \[1/0\] via 10.0.0.2

#   


### Example 2: Multiple Static Routes

Scenario:

Router A needs to reach two different networks:

RouterA(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2

RouterA(config)# ip route 172.16.0.0 255.255.0.0 10.0.0.3

#   


Result:

- Packets destined for 192.168.2.x go to 10.0.0.2
- Packets destined for 172.16.x.x go to 10.0.0.3

### Static Route Configuration with Exit Interface

Alternative Syntax (for point-to-point links):

Router(config)# ip route &lt;destination-network&gt; &lt;subnet-mask&gt; &lt;exit-interface&gt;

#   


Example:

RouterA(config)# ip route 192.168.2.0 255.255.255.0 Serial0/0/0

#   


Translation: "To reach 192.168.2.0/24, send out my Serial0/0/0 interface"

When to use:

- Point-to-point WAN links (Serial, PPP)
- When only one neighbor on the link
- More efficient on point-to-point connections

Difference:

<div align="left" dir="ltr" id="bkmrk-method-use-case-next"><table><colgroup><col width="110"></col><col width="458"></col></colgroup><tbody><tr><td>Method

</td><td>Use Case

</td></tr><tr><td>Next-Hop IP

</td><td>Multi-access networks (Ethernet, Frame Relay with many neighbors)

</td></tr><tr><td>Exit Interface

</td><td>Point-to-point links (Serial, PPP)

</td></tr></tbody></table>

</div>### Example 3: Next-Hop vs Exit Interface

Next-Hop (for Ethernet):

RouterA(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2

 ↑

 specific neighbor IP

#   


Exit Interface (for Serial):

RouterA(config)# ip route 192.168.2.0 255.255.255.0 Serial0/0/0

 ↑

 output interface

#   


---

## Default Route

### What is a Default Route?

A default route is a "catch-all" route that handles packets destined for networks the router doesn't have specific routes for.

Use: Send unknown destinations to a central router or ISP gateway

### Default Route Configuration

Syntax:

Router(config)# ip route 0.0.0.0 0.0.0.0 &lt;next-hop-ip&gt;

#   


Or in CIDR notation:

Router(config)# ip route 0.0.0.0/0 &lt;next-hop-ip&gt;

#   


Translation: "For any destination I don't have a more specific route for, send to this router"

Common notation: The default route is often written as 0.0.0.0/0 (the "default route")

### Example: Setting a Default Route

Scenario:

Small office network with single ISP connection

Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1

#   


Translation: "For any destination not in my routing table, send to the ISP gateway at 203.0.113.1"

Result:

S\* 0.0.0.0/0 \[1/0\] via 203.0.113.1

 \* indicates this is the default route

#   


### Route Precedence (Most Specific Wins)

When multiple routes match a destination, the router uses the most specific route:

Routing table:

0.0.0.0/0 → 203.0.113.1 (default route)

192.168.2.0/24 → 10.0.0.2 (specific route)

192.168.2.0/25 → 10.0.0.3 (more specific)

#   


Packet destined for:

#   


192.168.2.10 → Uses 192.168.2.0/25 (longest prefix match — /25 most specific)

192.168.3.10 → Uses 0.0.0.0/0 (default — no other match)

172.16.0.1 → Uses 0.0.0.0/0 (default — no other match)

#   


---

## Static Routing Configuration Example

### Complete Scenario

Network setup:

 \[PC A\]

 |

 \[Switch\]

 |

 Router A ────WAN Link──── Router B ────\[Switch\]──── \[PC B\]

 10.0.0.1 (Serial) 10.0.0.2 192.168.1.0/24

Router A is in: 10.0.0.0/24

Router B is in: 10.0.0.0/24 and 192.168.1.0/24

#   


Requirements:

- PC A (in 10.0.0.0 LAN) needs to reach PC B (in 192.168.1.0 LAN)
- Need static routes on both routers

Configuration on Router A:

RouterA(config)# ip route 192.168.1.0 255.255.255.0 10.0.0.2

RouterA(config)# end

#   


RouterA# show ip route

S 192.168.1.0/24 \[1/0\] via 10.0.0.2

#   


Configuration on Router B:

RouterB(config)# ip route 10.0.0.0 255.255.255.0 10.0.0.1

RouterB(config)# end

#   


RouterB# show ip route

S 10.0.0.0/24 \[1/0\] via 10.0.0.1

#   


Result:

- Router A knows how to reach 192.168.1.0/24 (sends to Router B)
- Router B knows how to reach 10.0.0.0/24 (sends to Router A)
- PC A can now ping and communicate with PC B

### Verifying Routes

Check routing table:

Router# show ip route

#   


Test connectivity:

Router# ping 192.168.1.100

#   


Trace packet path:

Router# traceroute 192.168.1.100

#   


---

## Comparison: Static vs Dynamic Routing

### When to Use Static Routing

✅ Good for:

- Small networks (&lt; 10 routers)
- Simple, stable topologies
- Point-to-point links
- High security requirements
- Lab/testing environments
- When you want complete control

❌ Not good for:

- Large networks
- Complex topologies
- Frequent topology changes
- Networks requiring redundancy
- Automatic failover

### When to Use Dynamic Routing

✅ Good for:

- Large networks (&gt; 10 routers)
- Complex topologies
- Multiple paths to destinations
- Automatic redundancy/failover
- Networks that change frequently
- Production enterprise networks

❌ Not good for:

- Very small networks (overhead not worth it)
- When bandwidth is extremely limited
- When security isolation is critical
- Simple point-to-point links

---

## Static Route Commands Reference

### Configuration

<div align="left" dir="ltr" id="bkmrk-command-purpose-ip-r"><table><colgroup><col width="297"></col><col width="165"></col></colgroup><tbody><tr><td>Command

</td><td>Purpose

</td></tr><tr><td>ip route &lt;dest&gt; &lt;mask&gt; &lt;next-hop&gt;

</td><td>Add static route

</td></tr><tr><td>ip route &lt;dest&gt; &lt;mask&gt; &lt;exit-int&gt;

</td><td>Add route via interface

</td></tr><tr><td>ip route 0.0.0.0 0.0.0.0 &lt;next-hop&gt;

</td><td>Configure default route

</td></tr><tr><td>no ip route &lt;dest&gt; &lt;mask&gt; &lt;next-hop&gt;

</td><td>Delete static route

</td></tr></tbody></table>

</div>### Verification

<div align="left" dir="ltr" id="bkmrk-command-purpose-show"><table><colgroup><col width="211"></col><col width="239"></col></colgroup><tbody><tr><td>Command

</td><td>Purpose

</td></tr><tr><td>show ip route

</td><td>Display entire routing table

</td></tr><tr><td>show ip route static

</td><td>Show only static routes

</td></tr><tr><td>show ip route 192.168.1.0

</td><td>Show route for specific destination

</td></tr><tr><td>ping &lt;ip&gt;

</td><td>Test connectivity

</td></tr><tr><td>traceroute &lt;ip&gt;

</td><td>Trace path to destination

</td></tr></tbody></table>

</div>### Example Session

Router# configure terminal

Router(config)# ip route 192.168.2.0 255.255.255.0 10.0.0.2

Router(config)# ip route 192.168.3.0 255.255.255.0 10.0.0.2

Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.1

Router(config)# exit

#   


Router# show ip route

 10.0.0.0/24 is directly connected, GigabitEthernet0/0

S 192.168.2.0/24 \[1/0\] via 10.0.0.2

S 192.168.3.0/24 \[1/0\] via 10.0.0.2

S\* 0.0.0.0/0 \[1/0\] via 203.0.113.1

#   


Router# ping 192.168.2.100

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echoes to 192.168.2.100, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/5 ms

#   


---

## Key Differences: Switches vs Routers in Network

<div align="left" dir="ltr" id="bkmrk-feature-switch-route"><table><colgroup><col width="190"></col><col width="143"></col><col width="186"></col></colgroup><tbody><tr><td>Feature

</td><td>Switch

</td><td>Router

</td></tr><tr><td>Layer

</td><td>Layer 2 (Data Link)

</td><td>Layer 3 (Network)

</td></tr><tr><td>Forwards within/between

</td><td>Within LANs

</td><td>Between LANs/Networks

</td></tr><tr><td>Uses

</td><td>MAC addresses

</td><td>IP addresses

</td></tr><tr><td>Table

</td><td>MAC address table

</td><td>Routing table

</td></tr><tr><td>Decision

</td><td>Destination MAC

</td><td>Destination IP

</td></tr><tr><td>Broadcasts

</td><td>Floods to all ports

</td><td>Blocks/filters

</td></tr><tr><td>Default behavior

</td><td>Active

</td><td>Interfaces down by default

</td></tr></tbody></table>

</div>---

## Key Takeaways for CCNA

✅ Routing is how packets move between different networks using destination IP addresses

✅ Routing table stores all known routes; router uses it for forwarding decisions

✅ Static routing = manual configuration; good for small, stable networks

✅ Dynamic routing = automatic discovery; good for large, complex networks

✅ WAN connects separate LANs over large geographic distances

✅ Default route (0.0.0.0/0) catches packets with no other matching route

✅ Static route syntax: ip route &lt;destination&gt; &lt;mask&gt; &lt;next-hop-ip&gt;

✅ Exit interface method used for point-to-point links; next-hop method for multi-access

✅ Routes point to next-hop IP or exit interface — tells router where to send packets

✅ Most specific route wins when multiple routes match a destination (longest prefix match)

✅ Router must have routes in both directions for bidirectional communication

✅ Directly connected routes appear as 'C' in routing table; don't need to be configured

✅ Local routes (L) are the router's own IP addresses; handled automatically

✅ show ip route displays routing table; includes source and metric information

✅ Routers separate broadcast domains — broadcasts don't cross router interfaces