Routing Fundamentals

Done

Routing

It is the process the routers use to choose the path IP packets should take over a network to reach its destination.

Routers store all known destinations to its routing table.

When routers receive packets, they check their routing table to choose the best path to forward an IP packet.

The Routing Table is populated by 2 methods:

Route

It tells the router that to reach a Destination X, it should forward the packet to the next-hop Y or If the destination is connected directly to it or if it is intended for it, send to itself.

đź’ˇ
Next-hop = It means the next router in the path to the destination.

Automatically added routes

After assigning an IP Address and enabling an interface, 2 types of routes are added:

đź’ˇ
A router matches a packet’s destination if that destination’s IP address has the network portion as the one specified in the route

A router will choose the most specific address in order to select a route. For example, if it receives a packet for 192.168.1.1, It will forward the packet to the local rather than the connected one, because 1 is more specific than 256.

đź’ˇ
Most specific matching route = the route with the longest prefix

Static Routing

When a endhost needs to send a package outside its network (LAN), it forward it to the default gateway.

đź’ˇ
A default gateway is also called a default route. This means 0.0.0.0/0, it by itself means all possible addresses (0.0.0.0 - 255.255.255.255)

Set Static Route

Option #1 - Next-Hop IP Address
configure terminal // Global Config Mode
ip route 192.168.15.0 255.255.255.0 192.168.45.4 //ip route {ip-address} {netmask} {nexthop}
Option #2 - Interface
configure terminal // Global Configuration Mode
ip route 192.168.15.0 255.255.255.0 g0/1//ip address {ip-address} {netmask} {exit-interface}
đź’ˇ
Note: This method relies on Proxy ARP and says on the routing table that it is directly connected to a subnet. Usually you can stick to the other options, neither of them are better.
Option #3 - Both
configure terminal // Global Configuration Mode
ip route 192.168.15.0 255.255.255.0 g0/1 192.168.45.4 //ip address {ip-address} {netmask} {exit-interface} {next-hop}

Default Route (Default Gateway)

If a packet has a destination’s IP address that matches no routes in the routing table, it will forward the packet to the next-hop specified.

configure terminal // Global Configuration Mode
ip route 0.0.0.0 0.0.0.0 192.168.50.3 //ip route 0.0.0.0 0.0.0.0 {next-hop}

Filter search in running-config

show running-config | include ip route //show {file} | include {term}