ARP, gateway, and routing table
For a packet to reach a neighbor, its MAC is needed. To reach another subnet, a gateway, correctly configured routes there and back, and the selection of the most precise mask in the table are required.
The main routing rule and the ARP protocol
The host first searches for a route to the destination IP. A connected network route is created based on the interface address and its prefix. In a simple network with one interface, to check for inclusion in this prefix, it is sufficient to compare SrcIP AND Mask Wi-Fi 6 DstIP AND Mask.
- Same subnet: delivery directly to the recipient's MAC address (On-link) via Switch — the router does not participate in this exchange.
- Different subnet: the frame is addressed to the next-hop MAC from the selected route. Often this is the default gateway. The destination IP address remains in the IP packet itself.
- ARP protocol (Address Resolution Protocol): translates a known IPv4 to a physical MAC only within the local segment. If there is no entry in the ARP cache (
arp -a), the PC sends a broadcast ARP Request (“Who has IP X.X.X.X?”), and the owner responds directly ARP Reply.
Three subnets: how MAC and TTL change
In the training network, the router connects LAN 1 (192.168.10.0/24), LAN 2 (192.168.20.0/24) and LAN 3 (192.168.30.0/24). Each switch forwards frames within its LAN. The router selects the output network by IP.
| Segment | Computers | Router Interface (Gateway) | Role |
|---|---|---|---|
| LAN 1 | 192.168.10.2, 192.168.10.3 | 192.168.10.1 | Switch 1 connects PC1 ↔ PC2 and leads to the router's LAN1 |
| LAN 2 | 192.168.20.2, 192.168.20.3 | 192.168.20.1 | Switch 2 works only by MAC within LAN 2 |
| LAN 3 | 192.168.30.2, 192.168.30.3 | 192.168.30.1 | Switch 3 serves LAN 3 independently of the others |
How Switch (L2) Wi-Fi 6 Router (L3) work together when sending from PC1 (192.168.10.2) to PC2 (192.168.20.2): The switch does not look at the IP — it forwards the frame by Dst MAC. Therefore, PC1 uses ARP to search not for the MAC of the distant PC2, but for the MAC of its gateway (192.168.10.1). The router strips the frame, reads the destination IP, selects the output LAN2, finds the MAC of PC2 via ARP, and creates a new Ethernet frame: IP addresses are preserved, but MAC addresses change at each segment!
.1 of its network. Three router interfaces are connected to different LANs. For packet forwarding, IP forwarding must be enabled, and filtering rules must allow the exchange.How the router reads the table: Longest Prefix Match
A route table row contains: Destination network, Mask (prefix), Gateway (Next-Hop / On-link), Interface Wi-Fi 6 Metric (path cost). The router (and PC) always selects the appropriate entry with the longest prefix match:
Only if the prefixes of the matched routes are of the same length, are compared metric Wi-Fi 6 administrative distance (route source). The default route 0.0.0.0/0 is triggered only when no more specific route matches.
Static, dynamic (RIP, OSPF) and the return path rule
Routes to directly connected subnets appear in the table automatically when IP is configured on interfaces. For remote networks, routes are set in two ways:
- Static routing: configured by the administrator (
route addin Windows orip route addin Linux). It is predictable and does not waste traffic on overhead, but it will not reconfigure itself if the line goes down. - Dynamic protocols (Routing Protocols): routers exchange a network map themselves — for example, RIP (metric is hop count up to 15, distance-vector) and OSPF (considers channel bandwidth, Dijkstra's algorithm). Both belong to interior protocols (IGP, within one organization), while the global Internet between autonomous systems (AS) connects via the exterior protocol BGP (EGP).
R1 knows the way to PC B, the packet with the response will not return to PC A until on R2 a return route to PC A's network is configured! Checking ping requires connectivity in both directions.