Concepts / Routers and routes

Routers and routes

Router

Also called layer 3, forwarding, ip_forward

A device on several networks that forwards packets between them, by destination address.

A router keeps the packet and changes the frame
A router keeps the packet and changes the frame

At each hop the router takes the IP packet out of the incoming frame, looks up the destination, lowers the TTL by one and puts the packet in a new frame for the outgoing link: its own MAC as sender, the next machine's MAC (from ARP) as receiver. The IP source and destination are unchanged end to end. A Linux host forwards like this only with net.ipv4.ip_forward = 1.

For each packet it looks up the destination in its routing table, lowers the TTL by one, rewrites the frame's MAC addresses for the next link and sends it on. A host becomes a router when forwarding is turned on (net.ipv4.ip_forward).

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab