Files
CCNA-Notes/11. Static Routing.md
2026-04-30 13:49:46 +00:00

6.8 KiB

id, aliases, tags
id aliases tags
1777544578-NSAK
Static Routing
CCNA
Router

Static Routing

Network diagram

Diagram

Default Gateway

End hists like PC1 and PC4 can send packets directly to destinations in their connected network.

  • PC1 is connected to 192.168.1.0/24, PC4 is connected to 192.168.4.0/24

To send packets to destinations outside of their local network, they must send the packets to their default gateway.

iface eth0 inet static
  address 192.168.1.10/24
  gateway 192.168.1.1
iface eth0 inet static
  address 192.168.4.10/24
  gateway 192.168.4.4

The default gateway configuration is also called a default route.

  • It is a route to 0.0.0.0/0 = all netmask bits set to 0. Includes all addresses 0.0.0.0 -> 255.255.255.255

    The default route is the least specific route possible, because it includes all [[IP addresses]].
    0.0.0.0 = 4,294,967,296 IP addresses
    A /32 route (ie. Local route) is the most specific route possible, because it specifies only one IP address
    192.168.1.1/32 = 1 IP address
    

End hosts usually have no need for any more specific routes.

  • They just need to know: to send packets outside of my local network, I should send them to my default gateway

    • Src. IP: 192.168.1.10
    • Dst. IP: 192.168.4.10
    • Dst. MAC = R1 G0/2 MAC
    • Src. MAC = PC1 eth0 MAC
      • to learn R1 G0/2's MAC address, PC1 will first send an ARP request to 192.168.1.1
  • When R1 Receives the frame from PC1, it will de-encapsulate it (remove L2 header/ trailer) and look at the inside packet.

  • It will check the routing table for the most-specific matching route:

  • R1 has no matching routes in irs routing table.

    • It will drop the packet.
  • To properly forward the packet, R1 needs a route to the destination network (192.168.4.0/24)

    • Routes are instructions: to send a packet to destinations in network 192.168.4.0/24, forward the packet to next hop Y
  • There are two possible path packets from PC1 to PC4 can take:

    1. PC1 -> R1 -> R3 -> R4 -> PC4
    2. PC1 -> R1 -> R2 -> R4 -> PC4
    • (it will be learn later)

Static Route configuration

Each router in the path needs two routes: a route to 192.168.1.0/24 and a route to 192.168.4.0/24.

  • this ensures two-way reachability (PC1 can send packets to PC4, PC4 can send packets to PC1).

    routers don't need routes to all networks in the path to the destination.
      - R1 doesn't need a route to 192.168.34.0/24.
      - R4 doesn't need a route to 192.168.13.0/24.
    
  • R1 already has a Connected route to 192.168.1.0/24

  • R4 already has a Connected route to 192.168.4.0/24

    • The other routes must be manually configured (using Static Routes)

Static Route Chart

Router Destination Next-Hop
R1 192.168.1.0/24 Connected
R1 192.168.4.0/24 192.168.13.3
R3 192.168.1.0/24 192.168.13.1
R3 192.168.4.0/24 192.168.34.4
R4 192.168.1.0/24 192.168.34.3
R4 192.168.4.0/24 Connected

R1 Configuration

For configuring Static route the command is:

R1(config)# ip route ip-address netmask next-hop

so for R1:

R1(config)# ip route 192.168.4.0 255.255.255.0 192.168.13.3

To check the routes

R1(config)# do show ip route

Codes: L - local, C - connected, S - static ....

//partial return

192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/2  
L 192.168.1.1/32 is directly connected, GigabitEthernet0/2  
S 192.168.4.0/24 [1/0] via 192.168.13.3 
  The [1/0] displayed in static routes means:
  [adminstrative Distance/Metric]
  We will cover these concepts later in the course.

so for R3:

R3(config)# ip route 192.168.1.0 255.255.255.0 192.168.13.1
// to send packets to 192.168.1.0/ 24 send packets to R1 
R3(config)# ip route 192.168.4.0 255.255.255.0 192.168.34.4
// to send packets to 192.168.4.0/ 24 send packets to R4 

so for R4:

R4(config)# ip route 192.168.1.0 255.255.255.0 192.168.34.3

Test connection

Now to see if PC1 and PC4 can communicate

PC1:$ ping 192.168.4.10
5 packets transmitted, 5 packets received, 0% packet loss

If the ping is successful, that means there is two-way reachability. PC1 can reach PC4, and PC4 can reach PC1

Static Route Configuration with exit-interface

instead of configuring a next hop we can configure an exit interface instead of the ip address we can specify the interface

We will do this for R2:

R2(config)# ip route ip-address netmask exit-interface
R2(config)# ip route 192.168.1.0 255.255.255.0 g0/0

but we can do both exit-interface and next-hop

R2(config)# ip route ip-address netmask exit-interface next-hop
R2(config)# ip route 192.168.4.0 255.255.255.0 g0/1 192.168.24.4

so it returns

R2(config)# do show ip route

// exit interface
S   192.168.1.0/24 is directly connected, GigabitEthernet0/0

// exit interface and next-hop
S   192.168.4.0/24 [1/0] via 192.168.24.4, GigabitEthernet0/1
  • Static routes in which you specify only the exit-interface rely on a feature called Proxy ARP to function
  • This is usually not a problem, but generally you can stick to
    • next-hop or exit-interface next-hop
  • Neither is 'better' than the other: use which you prefer.

Default route

  • A default route is a route to 0.0.0.0/0

    • 0.0.0.0/0 is the least specific route possible; it includes every possible destination IP address.
  • if the router doesn't have any more specific routes that match a packet's destination IP address, the router will forward the packet using the default route.

  • A default route is often used to direct traffic to the Internet.

  • Example for a internal corporate network.:

    • More specific routes are used for destinations in the internal corporate network.
    • Traffic to destinations outside of the internal network is sent to the internet.

example

configure default route

R1# show ip route
Gateway of last resort is not set

No default route has been configured yet To configure a default route use this command

R1(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2

//check
R1(config)# do show ip route
* - candidate default

S*  0.0.0.0/0 [1/0] via 203.0.113.2

Review

R2(config)# ip route ip-address netmask next-hop
R2(config)# ip route ip-address netmask exit-interface
R2(config)# ip route ip-address netmask exit-interface next-hop
  • Default Routes