Introduction to Routing
Basic Concepts
At an abstract level, routing is building maps and giving directions to incoming packets. We do this by directing different packets to different locations based on 2 criteria: destination and netmask. These packets are then forwarded on to a “next hop” location. This is called classic or destination-based forwarding and is supported by all routers and most hosts.
These three elements (destination, netmask, and next hop) are what make up the basics of routing. The destination is the IP address of wherever the client has requested to go. The netmask (also called prefix length) of the route is a set of bits that the router looks at.
An ipv4 address has 32 bits. A route will look like this:
192.0.192.0/24 or 192.0.192.0 255.255.255.0
The /24 is saying that the router should match ONLY the first 24 bits of the route against a packet when determining whether to use the route for that packet.
Each piece (what is between the dots) of an ipv4 address is 8 bits long.
So, the first 24 bits of this route are: 192.0.192
In binary [base2] the bits look like this:
[must match................][not used...................]
11000000.00000000.11000000.00000000
So, any ipv4 destination that matches 192.0.192.x will use that route:
Example: 192.0.192.3 is:
11000000 00000000 11000000 00000011
and since the first 24 bits match, the route can be used.
IPv6 works in a similar fashion but the notation is different. Instead of using base10 notation with bytes separated by dots like ipv4, ipv6 uses a hex digit for each half byte (4 bits) with leading zeroes suppressed inside each group. Colons separate each group of 2 bytes:
Examples:
ipv6 address: 2620:a8:c000:999::21/64
ipv6 route: 2620:a8:c000:999::/64
[must match……………..][not used………………….]
2620:00a8:c000:0999:0000:0000:0000:0000
Users sometimes think of routes as having a subnet and a subnet mask, but this is technically incorrect. For example, a supernet route can represent many subnets with a single entry in a router.
For example, a company may have 4 subnets on their network:
192.168.10.0/24 HR
192.168.20.0/24 Sales
192.168.30.0/24 Engineering
192.168.40.0/24 R&D LAB
A VPN tunnel that is established does not have to have 4 routes to provide connectivity for all 4 subnets.
Instead, a single route destination 192.168.0.0/16 could be added to the VPN router to push traffic destined for any 192.168.* network.
This is why it’s important to combine the destination and route length into a prefix while remembering the route itself has 2 subcomponents.
If you try to represent a route or prefix incorrectly many operating systems will refuse to accept the route or cisco will autocorrect the route for you.
For example, if you enter a route for:
192.168.1.230/24 next hop of 10.10.1.1 into a Cisco it will convert the route for you into 192.168.1.0 255.255.255.0 (192.168.1.0/24).
The reason for this is that all of the bits in the not-used section must be zeroed out.
Some common prefix lengths you will see:
/32 (used for loopback addresses)
/30 (used on point-to-point links)
/29 (used by broadband ISPs for a chunk of 5 usable public IPs)
/24 (common ipv4 LAN subnet)
/22 (used on large wireless LANs)
/16 (supernet routes for large chunks of space)
/0 (default route – also 0/0)
All next hop addresses must be directly accessible (using ARP) from an interface unless you have recursive routing enabled.
Types of Routes
Connected
A connected route is a route where two devices can communicate directly. Connected routes only exist for devices that share a LAN. No routing is done because the packets simply travel through the router’s LAN interface. For example, if you have two computers connected to the same LAN, their route to one another is connected.
Static
Static routing is the most basic form of routing. It is programmed in by the user and does not change unless the user changes it.
The most precise static route will always be chosen before the most general one. For example, if you have these two routes:
0.0.0.0/0 via 172.30.100.1
192.168.1.0/24 via 172.30.100.10