Routing & Switching
What routers and switches do
- Switch (L2): forwards frames within a LAN based on MAC addresses.
- Router (L3): forwards packets between networks based on IP routes.
MAC vs IP addressing
- MAC: link-layer identifier on a local network segment; used for local delivery.
- IP: network-layer address; used for end-to-end routing across networks.
- Same host often has both: IP for routing, MAC for the local hop.
ARP protocol
- ARP resolves IPv4 address → MAC address on a LAN.
- Host asks “Who has IP X?” and receives the MAC to send frames to.
- ARP caches mappings; spoofing/poisoning is a classic LAN attack.
Routing tables
- A router/host chooses the “best match” route (longest prefix match) for a destination IP.
- Routes can be static or learned dynamically (OSPF/BGP/etc.).
Default gateway concept
- When destination is outside the local subnet, send traffic to the default gateway.
- The gateway routes it onward (or drops it if no route).