Routers sit at the boundaries between networks and decide where packets go next. They look at destination IP addresses, consult their routing tables and forward traffic towards the best next hop.
In this module you will see how routers perform routing and forwarding, what information is stored in a routing table and how NAT and PAT make it possible for many private devices to share a small pool of public addresses.
"Routers are the sat nav of the Internet. They do not care what is in your packet, only where it needs to go next."
π What you will learn
- How routers route traffic between different IP networks
- What information a routing table stores and how routes are chosen
- The difference between routing and forwarding on a router
- How NAT translates private IP addresses into public ones
- How PAT allows many private devices to share a single public address using ports
π‘ Routing and forwarding
At a high level, routers perform two related tasks. Routing is the process of building and maintaining the routing table using static entries or dynamic routing protocols. Forwarding is the act of taking an incoming packet and sending it out of the correct interface based on that table.
- Routing protocols such as OSPF, RIP and IS IS exchange information with other routers.
- The routing table stores destination networks, masks, next hops, outgoing interfaces and metrics.
- The router chooses the best matching route and forwards the packet out of the corresponding interface.
π Network Address Translation (NAT)
Many internal networks use private address ranges that are not routable on the public Internet. NAT converts internal private addresses to one or more public addresses at the edge of the network.
- Outbound packets have their source address rewritten to a public IP address.
- The router keeps a translation table so that reply traffic can be mapped back to the original internal host.
π Port Address Translation (PAT)
PAT is a common form of NAT that allows many internal devices to share a single public IP address. It does this by using different source port numbers for each internal connection.
- Each internal flow is mapped to a unique combination of public IP address and port.
- Return traffic is matched to the right internal host using this mapping.
- This conserves public IPv4 addresses and is widely used on home and office routers.
β Key takeaway
Routers make large scale networking possible by learning routes, forwarding packets between networks and translating between private and public addressing with NAT and PAT.