Module 5

Routing, Switching, and Network Infrastructure

Routing tables, static and dynamic routing, NAT/PAT, firewalls, VLANs, and enterprise network design.

Introduction

Module 4 focused on IP addressing and subnetting. This chapter builds on that foundation by showing how packets actually move across multiple networks, how routers choose paths, and how organizations secure and segment their infrastructure at the network edge and inside the LAN.

The chapter moves from Layer 3 routing into boundary services such as NAT and firewalls, then finishes with VLANs and trunking. Those topics matter together because real networks rarely stop at a single switch or a single subnet.

graph LR
    PC["fa:fa-desktop Source PC
192.168.1.10"] --> SW["fa:fa-network-wired Switch"] SW --> R1["fa:fa-wifi Router"] R1 --> C["fa:fa-cloud Internet"] C --> R2["fa:fa-wifi Router"] R2 --> SW2["fa:fa-network-wired Switch"] SW2 --> S["fa:fa-server Destination Server"] style PC fill:#e8f1fb,stroke:#004a88 style SW fill:#f0fdf4,stroke:#16a34a style R1 fill:#fff7e0,stroke:#d97706 style R2 fill:#fff7e0,stroke:#d97706 style C fill:#f4f7fb,stroke:#004a88 style SW2 fill:#f0fdf4,stroke:#16a34a style S fill:#e8f1fb,stroke:#004a88

Figure 1: A packet's path through routing infrastructure. Layer 3 addresses stay constant end-to-end, while Layer 2 addresses change at each hop.

Review from Module 4

Module 4 explained that IP addresses identify networks and hosts, while MAC addresses identify hardware on a local link. Routers use the destination IP to decide where a packet should go next. That decision is what makes communication across separate networks possible.

Core Distinction

Switches forward frames using MAC addresses at Layer 2. Routers forward packets using IP addresses at Layer 3.

Learning Outcomes

After completing this module, you will be able to:

  • Explain how routers forward packets using routing tables and longest prefix match.
  • Compare static routing, dynamic routing, and default routes.
  • Interpret traceroute output and common router diagnostic commands.
  • Describe RIP, EIGRP, OSPF, and BGP at a high level.
  • Explain NAT, PAT, firewall types, and DMZ placement.
  • Design and secure VLAN-based segmentation with trunking and voice VLANs.

Routing Foundations

Routing Foundations

Router: Gateway Between Networks

A router connects different networks at Layer 3. Each interface belongs to a different subnet, and the router uses the destination IP address to decide the best outgoing interface or next hop. Every packet passing through a router has its TTL decremented by one.

graph LR
    subgraph A["Network A: 192.168.1.0/24"]
        PC1["fa:fa-desktop PC"]
        PC2["fa:fa-desktop PC"]
    end
    R["fa:fa-wifi Router"]
    subgraph B["Network B: 10.0.0.0/24"]
        SRV["fa:fa-server Server"]
        PC3["fa:fa-desktop PC"]
    end
    C["fa:fa-cloud Internet"]
    PC1 --> R
    PC2 --> R
    R --> SRV
    R --> PC3
    R --> C

    style R fill:#fff7e0,stroke:#d97706,stroke-width:3px
            

Figure 2: The router sits between networks and the wider internet. Each interface is assigned to a different subnet.

Why Routers Matter

Switches keep traffic local inside a broadcast domain. Routers move traffic between broadcast domains and can apply policy, translation, and filtering at the edge.

Routing Tables and Path Selection

Every router keeps a routing table containing known destination networks, next hops, and metrics. When a packet arrives, the router reads the destination IP, searches the table, and selects the most specific matching entry. That rule is called longest prefix match.

graph TD
    A["Packet arrives"] --> B["Read destination IP"]
    B --> C["Search routing table"]
    C --> D["Find longest prefix match"]
    D --> E["Forward to next hop or exit interface"]
            

Figure 3: Routing is a simple decision chain. The router never guesses; it matches the destination address against known prefixes and forwards accordingly.

Static and Default Routes

Static Routes

Static routes are manually configured and stay in place until an administrator changes them. They are predictable and useful for small or tightly controlled networks.

ip route 10.0.0.0 255.0.0.0 192.168.1.1
Default Route

The route of last resort handles anything not matched more specifically.

ip route 0.0.0.0 0.0.0.0 203.0.113.1

Routing Table Example

A real routing table usually includes directly connected networks, static entries, and a default route. The router prefers the most specific valid entry; if no specific route exists, it falls back to the default route.

NetworkMaskNext HopMetricType
192.168.1.0/24Gig0/00Direct
10.0.0.0/24Gig0/10Direct
172.16.0.0/1610.0.0.21Static
0.0.0.0/0192.168.1.2541Default

Packet Forwarding Process

A router changes the Layer 2 header at each hop because it has to deliver the packet across the next local link. The Layer 3 source and destination addresses stay the same end-to-end, but the source and destination MAC addresses are replaced at every hop.

graph LR
    A["Incoming frame
Src MAC / Dst MAC
Src IP / Dst IP"] --> R["fa:fa-wifi Router
Lookup + TTL--"] R --> B["Outgoing frame
New Src MAC / New Dst MAC
Same Src IP / Same Dst IP"]

Figure 4: The router rewrites Layer 2 addresses while preserving Layer 3 addresses. That is why a packet can cross many routers without changing its IP identity.

Fragmentation and MTU

The MTU is the largest packet payload a link can carry. Standard Ethernet uses an MTU of 1500 bytes. If a packet is too large, it must be fragmented or dropped. Modern systems try to avoid fragmentation by using Path MTU Discovery.

Why Fragmentation Hurts

Fragmentation adds processing overhead, and if a single fragment is lost, the entire packet has to be retransmitted.

Case Study: Westley’s Journey to Florin

Case Study — Westley’s Journey to Florin

Westley is sending a message from the Pirate Ship network to Castle Florin. His router knows a specific route to the castle network and a default route for everything else.

Review questions:

  1. Which route will the router use?
  2. What happens if the specific route is removed?
  3. Why is the default route important?
Solution — Westley’s Journey to Florin
  1. The router uses the most specific match, the route to Florin’s network.
  2. If that route is removed, the default route becomes the fallback.
  3. The default route is the route of last resort for all unknown destinations.

Router Configuration and Tools

Router Configuration and Tools

Basic Router Configuration

At minimum, a router needs interface IP addresses, enabled interfaces, a hostname, and whatever routes are necessary to reach other networks. In practice, administrators also configure passwords and save the running configuration after changes.

enable
configure terminal
hostname Florin-GW
interface g0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown
exit
ip route 0.0.0.0 0.0.0.0 203.0.113.1
copy run start

Routing Table Tools

Cisco / IOS
  • show ip route
  • show ip interface brief
  • show running-config
Windows / Linux
  • route print
  • netstat -r
  • ip route

tracert and traceroute

tracert on Windows and traceroute on Linux/macOS use TTL manipulation to reveal each hop along a path. The tool sends probes with increasing TTL values; each router along the path decrements the TTL and returns an ICMP Time Exceeded response until the destination is reached.

graph LR
    S["fa:fa-desktop Source"] --> H1["fa:fa-wifi Hop 1"] --> H2["fa:fa-wifi Hop 2"] --> H3["fa:fa-wifi Hop 3"] --> D["fa:fa-server Destination"]
    S -. "TTL=1" .-> H1
    S -. "TTL=2" .-> H2
    S -. "TTL=3" .-> H3
            

Figure 5: traceroute / tracert discovers the route one hop at a time by using TTL values that expire at successive routers.

Dynamic Routing Protocols

Dynamic Routing Protocols

Dynamic Routing Overview

Static routes are simple, but they do not adapt when links fail or new paths appear. Dynamic routing protocols share reachability information automatically and converge on new paths when the topology changes. Inside an organization they are called IGPs; between organizations, the internet uses BGP, an EGP.

graph LR
    subgraph A["AS 100 - Your Company"]
        R1["fa:fa-wifi Router"] --- R2["fa:fa-wifi Router"]
    end
    subgraph B["AS 200 - ISP"]
        R3["fa:fa-wifi Router"] --- R4["fa:fa-wifi Router"]
    end
    R2 ==>|"BGP"| R3
            

Figure 6: OSPF, RIP, and EIGRP are IGPs inside one organization. BGP is the inter-AS protocol used to exchange routes between organizations.

RIP and EIGRP

RIP

RIP uses hop count. It is simple, but it ignores link speed and caps routes at 15 hops.

EIGRP

EIGRP uses bandwidth and delay, converges quickly, and supports more advanced balancing behavior.

OSPF

OSPF is an open standard, link-state protocol. It builds a topology map and calculates route cost using bandwidth. Large networks use hierarchical areas with an Area 0 backbone and area border routers connecting other areas to the backbone.

graph TD
    A0["Area 0 Backbone"]
    A1["Area 1"]
    A2["Area 2"]
    A0 --- A1
    A0 --- A2
            

Figure 7: OSPF scales through hierarchy. Areas reduce route flooding and keep topology calculations manageable.

BGP

BGP is the protocol of the internet. It is used to exchange routing information between autonomous systems and is policy-driven rather than purely metric-driven. Enterprises use BGP when they need multihoming or control over upstream paths.

graph LR
    C["fa:fa-building Company AS"] --> I1["fa:fa-wifi ISP Alpha"]
    C --> I2["fa:fa-wifi ISP Beta"]
    I1 --> N["fa:fa-cloud Internet"]
    I2 --> N
            

Figure 8: BGP multihoming. A company can connect to multiple ISPs for redundancy and policy control.

Route Selection and Administrative Distance

When multiple sources know the same route, Administrative Distance decides which source to trust. Lower is better. Direct routes beat static routes, and static routes beat learned routing protocols.

Route SourceAdministrative Distance
Directly Connected0
Static Route1
EIGRP (internal)90
OSPF110
RIP120

Case Study: Inigo’s Path to Count Rugen

Case Study — Inigo’s Path to Count Rugen

Inigo has learned two routes to Count Rugen’s network. One route came from OSPF and the other from RIP. Both are valid, but one must be preferred.

Review questions:

  1. Which route will the router prefer?
  2. Why does that route win?
  3. What happens if the preferred route fails?
Solution — Inigo’s Path to Count Rugen
  1. The router prefers the OSPF route.
  2. OSPF has a lower Administrative Distance than RIP.
  3. If OSPF fails, the RIP route becomes the backup path.

Edge Services and Translation

Edge Services and Translation

Edge Routers and Network Boundaries

The edge router sits at the demarcation point between the internal network and the ISP. It can route, translate addresses, and enforce policy before traffic leaves or enters the organization.

graph LR
    subgraph LAN["Internal Network"]
        PC["fa:fa-desktop PC"] --> SW["fa:fa-network-wired Switch"] --> ER["fa:fa-wifi Edge Router"]
    end
    ER --> ISP["fa:fa-cloud ISP / Internet"]
            

Figure 9: The edge router is the first device that handles traffic leaving the local network and often the first line of policy enforcement.

Network Address Translation (NAT)

NAT translates private addresses into public addresses. It is one answer to IPv4 address exhaustion and lets many internal hosts share fewer public addresses.

graph LR
    P["fa:fa-desktop Private Host
192.168.1.10"] --> N["fa:fa-wifi NAT Router"] --> W["fa:fa-cloud Internet
203.0.113.50"]

Figure 10: NAT rewrites inside-local private addresses into inside-global public addresses on outbound traffic, then reverses the mapping for return traffic.

NAT Types

TypeDescriptionBest For
Static NATOne private address maps to one public addressServers needing stable public identity
Dynamic NATPrivate hosts use a pool of public addressesSmaller environments with spare public IPs

PAT: Port Address Translation

PAT lets many private devices share a single public IP address by tracking unique source ports. This is the most common home and small business setup.

graph LR
    A["192.168.1.10:12345"] --> R["fa:fa-wifi PAT Router\n203.0.113.1:40001"]
    B["192.168.1.11:12345"] --> R
    C["192.168.1.12:54321"] --> R
    R --> I["fa:fa-cloud Internet"]
            

Figure 11: PAT uses ports to multiplex many internal connections across one public address.

Firewall Uses and Types

Firewalls filter traffic according to policy. Most use a default-deny stance and only allow traffic that has been explicitly permitted. Stateful inspection and application awareness improve on simple packet filtering by tracking sessions and higher-layer data.

Firewall TypeSummary
Packet FilteringStateless, checks IPs and ports
Stateful InspectionTracks connection state
Application FirewallInspects application payloads
NGFWAdvanced inspection, IPS, and policy enforcement

Firewall Placement and DMZ

A DMZ is a screened subnet for public-facing servers. If a web or mail server in the DMZ is compromised, the internal LAN remains protected by the inner firewall.

graph TD
    I["fa:fa-cloud Internet"] --> F1["fa:fa-shield-halved Outer Firewall"]
    F1 --> D["fa:fa-server DMZ Servers"]
    D --> F2["fa:fa-shield-halved Inner Firewall"]
    F2 --> L["fa:fa-network-wired Internal LAN"]
            

Figure 12: A DMZ creates a buffer zone between the public internet and the internal LAN.

VLAN Segmentation and Trunking

VLAN Segmentation and Trunking

Introduction to VLANs

VLANs divide one physical switch into multiple logical broadcast domains. That improves security and performance because traffic from one VLAN does not automatically reach devices in another VLAN. If traffic needs to cross VLAN boundaries, a router or Layer 3 switch must handle it.

graph LR
    subgraph V10["VLAN 10 - Sales"]
        S1["fa:fa-desktop PC"]
        S2["fa:fa-desktop PC"]
    end
    subgraph V20["VLAN 20 - Engineering"]
        E1["fa:fa-laptop PC"]
        E2["fa:fa-laptop PC"]
    end
    SW["fa:fa-network-wired Switch"]
    S1 --> SW
    S2 --> SW
    E1 --> SW
    E2 --> SW
            

Figure 13: VLANs isolate groups of devices logically, even when they share the same physical switch.

VLAN Trunking and 802.1Q

A trunk carries traffic for multiple VLANs between switches or between a switch and a router. The 802.1Q tag identifies the VLAN so the receiving switch can place the frame in the correct logical network.

graph LR
    SW1["fa:fa-network-wired Switch 1"] --> T["802.1Q Trunk"] --> SW2["fa:fa-network-wired Switch 2"]
    SW1 --- A["VLAN 10"]
    SW1 --- B["VLAN 20"]
    SW2 --- C["VLAN 10"]
    SW2 --- D["VLAN 20"]
            

Figure 14: Trunk links transport multiple VLANs over one physical connection using 802.1Q tagging.

Voice VLANs

Voice VLANs keep phone traffic separate from general data traffic while still letting a desk phone act as a pass-through for the workstation behind it. That keeps voice traffic prioritized and simplifies cabling.

Why Voice VLANs Help

Voice is sensitive to delay and jitter. Giving it a dedicated VLAN and higher QoS priority keeps calls stable under load.

Native VLAN and Security

Untagged traffic on a trunk belongs to the native VLAN. If the two ends of a trunk disagree on the native VLAN, or if default VLAN 1 is used carelessly, the network can be exposed to VLAN hopping risks. Good practice is to move the native VLAN away from the default and keep it consistent on both ends.

Case Study: Miracle Max’s Potion Shop

Case Study — Miracle Max’s Potion Shop

Miracle Max separates potion brewing, customer sales, and billing into different VLANs. The sales team needs access to the brewing server, but the VLANs are isolated by default.

Review questions:

  1. Why can’t Sales talk directly to Brewing?
  2. What device is required to enable communication?
  3. What is that process called?
Solution — Miracle Max’s Potion Shop
  1. The VLANs are separate Layer 2 broadcast domains.
  2. A router or Layer 3 switch is required.
  3. The process is called inter-VLAN routing.

Module Summary

Module Summary

Module 5 Summary

Routing

  • Routers forward packets at Layer 3 using routing tables.
  • Longest prefix match selects the best route.
  • Static routes and default routes are simple and predictable.
  • Dynamic routing protocols adapt automatically to change.

NAT and Security

  • NAT and PAT conserve IPv4 addresses.
  • Firewalls enforce policy at the edge and between segments.
  • DMZs isolate public servers from the internal LAN.

VLANs

  • VLANs create logical broadcast domains on the same switch.
  • 802.1Q trunks carry multiple VLANs between devices.
  • Voice VLANs prioritize voice traffic and reduce cabling complexity.
  • Native VLAN handling matters for both compatibility and security.

Protocol Hierarchy

  • RIP, EIGRP, OSPF, and BGP serve different scopes.
  • Administrative Distance determines which learned route is trusted.
  • Enterprise design often combines routing, segmentation, and security at the edge.
Next Steps

Module 6 moves deeper into network services such as DHCP and DNS, which build on the routing and segmentation foundations introduced here.