IP addresses alone do not get a packet onto the wire. A host still has to learn which MAC address to put in the frame, where its own address comes from, how to report errors, and how to join multicast groups. Four small protocols do those jobs: ARP, DHCP, ICMP and IGMP. When a LAN misbehaves, one of them is usually involved.
ARP: from IP to MAC
A host wants to send a packet to 192.168.1.1. The IP packet is ready, but the Ethernet frame needs a destination MAC. The Address Resolution Protocol finds it:
- The host broadcasts an ARP request to
ff:ff:ff:ff:ff:ff: “Who has 192.168.1.1? Tell 192.168.1.42.” - The owner replies directly with an ARP reply: “192.168.1.1 is at 00:1a:2b:3c:4d:5e.”
- Both sides store the answer in their ARP cache for a while.
The key rule: a host only ARPs for addresses on its own subnet. For anything else it ARPs for its default gateway and sends the frame there.
$ ip neigh
192.168.1.1 dev enp3s0 lladdr 00:1a:2b:3c:4d:5e REACHABLE
192.168.1.77 dev enp3s0 lladdr 52:54:00:7a:11:02 STALE
192.168.1.90 dev enp3s0 FAILED
$ sudo ip neigh flush dev enp3s0
$ sudo tcpdump -i enp3s0 -nn arp -c 2
10:22:31.104411 ARP, Request who-has 192.168.1.1 tell 192.168.1.42, length 28
10:22:31.104802 ARP, Reply 192.168.1.1 is-at 00:1a:2b:3c:4d:5e, length 46
FAILED means nobody answered: the host is off, on another VLAN, or the address is wrong. On Windows, arp -a or Get-NetNeighbor shows the cache.
Gratuitous ARP
A host can announce its own mapping unasked (“192.168.1.10 is at aa:bb:…”). It is used to detect duplicate addresses at boot and to move a virtual IP between servers during failover (keepalived, VRRP, Pacemaker): the new owner sends gratuitous ARPs so every cache updates immediately.
ARP spoofing
ARP has no authentication. An attacker on the LAN can send fake replies claiming to be the gateway, and victims will send their traffic through the attacker (a man-in-the-middle). Defenses: Dynamic ARP Inspection and DHCP snooping on managed switches, separate VLANs, and encryption (TLS, SSH, VPN) so intercepted traffic is useless.
RARP
Reverse ARP did the opposite (MAC to IP) so diskless machines could learn their address at boot. It could not hand out a mask or gateway and needed a server on every subnet. BOOTP and then DHCP replaced it completely.
DHCP: automatic addressing
The Dynamic Host Configuration Protocol gives a host everything it needs to join a network: IP address, mask, default gateway, DNS servers, domain name, NTP servers and more. It runs over UDP: clients use port 68, servers port 67.
DORA
| Step | Message | From to | Meaning |
|---|---|---|---|
| D | Discover | Client broadcast | “I need an address. Any DHCP servers here?” |
| O | Offer | Server | “You can have 192.168.1.42 for 24 hours.” |
| R | Request | Client broadcast | “I accept the offer from that server.” (other servers withdraw theirs) |
| A | Acknowledge | Server | “Confirmed, here are your settings.” |
The client starts with no address, which is why Discover and Request use broadcast with source 0.0.0.0.
$ sudo tcpdump -i enp3s0 -nn 'port 67 or port 68' -c 4
10:30:01.001 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 3c:2c:4a:1b:9c:10, length 300 (Discover)
10:30:01.004 192.168.1.1.67 > 192.168.1.42.68: BOOTP/DHCP, Reply, length 300 (Offer)
10:30:01.010 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 3c:2c:4a:1b:9c:10, length 300 (Request)
10:30:01.013 192.168.1.1.67 > 192.168.1.42.68: BOOTP/DHCP, Reply, length 300 (ACK)
Leases, renewals and reservations
Addresses are leased, not given forever. At half the lease time the client asks its server to renew; at about 87.5% it asks any server. If the lease runs out, it must stop using the address. A reservation ties an address to a MAC so a printer or server always gets the same one, while still being managed centrally.
$ nmcli -f DHCP4 device show enp3s0 | grep -E 'ip_address|routers|domain_name_servers|dhcp_lease_time'
DHCP4.OPTION[4]: dhcp_lease_time = 86400
DHCP4.OPTION[7]: domain_name_servers = 192.168.1.1
DHCP4.OPTION[10]: ip_address = 192.168.1.42
DHCP4.OPTION[14]: routers = 192.168.1.1
$ sudo nmcli device reapply enp3s0
On Windows, ipconfig /release and ipconfig /renew drop and request a lease.
DHCP relay
Broadcasts do not cross routers, so a central DHCP server cannot hear clients on other VLANs. A DHCP relay (ip helper-address on Cisco) on each VLAN’s gateway catches the broadcast and forwards it as unicast to the server, adding the VLAN’s gateway address so the server knows which pool to use.
Rogue DHCP
Any device can answer Discovers. A home router plugged in backwards, or an attacker, can hand out wrong gateways. DHCP snooping on switches only allows server replies on trusted uplink ports.
ICMP: errors and diagnostics
The Internet Control Message Protocol (IP protocol 1; ICMPv6 for IPv6) carries error reports and diagnostics. It is how the network tells you something went wrong.
| Type | Name | Used by |
|---|---|---|
| 8 / 0 | Echo request / Echo reply | ping |
| 3 | Destination unreachable (code 0 net, 1 host, 3 port, 4 fragmentation needed) | Routers and hosts reporting failure; path MTU discovery |
| 11 | Time exceeded | traceroute, routing loops |
| 5 | Redirect | A router pointing a host to a better gateway |
$ ping -c 2 192.0.2.99
From 192.168.1.1 icmp_seq=1 Destination Host Unreachable
$ mtr -rwc 10 example.com
HOST: laptop Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.1.1 0.0% 10 0.6 0.6 0.5 0.8 0.1
2.|-- 100.64.0.1 0.0% 10 5.1 5.0 4.8 5.6 0.2
3.|-- 198.51.100.9 30.0% 10 6.3 6.4 6.1 7.0 0.3
4.|-- 203.0.113.80 0.0% 10 18.2 18.1 17.9 18.6 0.2
mtr combines ping and traceroute. Here hop 3 shows 30% loss, but later hops show 0%: that router just rate-limits ICMP replies to itself, which is normal. Real loss continues to every hop after the point where it starts.
Not getting a ping reply proves little. Many hosts and cloud firewalls drop ICMP echo. To test a service, test its port: nc -zv host 443 or curl -v https://host/.
IGMP: joining multicast groups
Multicast sends one stream to many receivers (IPTV, market data feeds, some service discovery). Hosts use IGMP (IP protocol 2) to tell their router which multicast groups (224.0.0.0/4) they want; IPv6 uses MLD, part of ICMPv6. IGMP snooping on switches watches these messages so multicast is only sent to ports that asked for it instead of being flooded everywhere.
$ ip maddr show dev enp3s0 | head -4
2: enp3s0
link 01:00:5e:00:00:01
link 33:33:00:00:00:01
inet 224.0.0.1
224.0.0.1 is the “all hosts” group that every IPv4 host joins.
Exercise
A host at 10.0.5.20/24 sends a packet to 8.8.8.8. Whose MAC address does it ARP for?
Show answer
Answer: A. 8.8.8.8 is not on the local subnet, so the frame goes to the gateway. The host ARPs for the gateway’s IP and puts that MAC in the frame.
Exercise
Clients on VLAN 30 get 169.254.x.x addresses, while VLAN 10 (where the DHCP server lives) works. What is the most likely fix?
Show answer
Answer: B. DHCP Discovers are broadcasts and do not cross routers. A relay on VLAN 30’s gateway forwards them to the server as unicast.
Exercise
Which ICMP message does traceroute rely on to discover each router?
Show answer
Answer: C. Each probe has a growing TTL. The router where the TTL hits zero drops it and returns ICMP time exceeded, revealing its address.
Key takeaways
- ARP maps IP to MAC on the local subnet; off-subnet traffic goes to the gateway’s MAC.
- ARP and DHCP have no authentication; switches defend with DAI and DHCP snooping.
- DHCP is Discover, Offer, Request, Acknowledge over UDP 67/68; relays carry it across VLANs.
- ICMP reports errors and powers ping, traceroute and path MTU discovery.
- IGMP (or MLD in IPv6) lets hosts join multicast groups.
FAQ
How long do ARP entries last?
On Linux an entry stays REACHABLE for about 30 seconds after confirmation, then turns STALE and is rechecked when used. Windows and switches have their own timers, often several minutes. You rarely need to touch them.
Can I give a fixed address to a device without DHCP?
Yes, configure it statically, but pick it from outside the DHCP pool to avoid conflicts. A DHCP reservation is usually better because it keeps all addresses in one place.
Why does my ping work but the website does not load?
Ping proves only layer 3 reachability. The web server port may be closed, a firewall may block TCP 443, TLS may fail, or DNS may point elsewhere. Test with curl -v.
Is it safe to block ICMP?
Blocking echo requests from the internet is a choice. Blocking all ICMP is not: “fragmentation needed” and “packet too big” messages must get through or path MTU discovery breaks.