linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/Networking: L2 / L3/arp

kb/network-l2-l3 ── Networking: L2 / L3 ── beginner

ARP: Address Resolution Protocol

ARP answers the question "who has MAC = ?" for a given IP inside one network. Linux keeps the result in the neighbor table (`ip neigh`).

view as markdownaka: arp-table, neighbor-table

Why ARP exists

A network card thinks in mac-addresses, not in IP. For host A to send an IP packet to host B in the same subnet, A must know B's MAC. ARP (RFC 826) is the protocol that resolves this mapping.

The algorithm:

  1. A wants to send to 192.168.1.20. It checks the neighbor table
  2. If there is no entry, A sends an ARP request as a broadcast: "who has 192.168.1.20? tell 192.168.1.10 (my MAC AA:BB:...)"
  3. B sees the request (it is addressed to B) and answers with a unicast: "192.168.1.20 is 00:1c:42:..."
  4. A caches the IP↔MAC pair in the neighbor table
  5. Now A can send an ethernet-frame straight to B

ARP works only inside one broadcast domain (one L2 network). It does not cross a router. There the routing-table takes over.

ARP in IPv6

In IPv6, ARP is replaced by NDP (Neighbor Discovery Protocol). The concept is the same, but it runs over ICMPv6 and multicast instead of broadcast. Linux merges both tables:

bash
ip -4 neigh    # IPv4 ARP
ip -6 neigh    # IPv6 NDP
ip neigh       # both together

Neighbor entry states

  • REACHABLE: the IP↔MAC pair was confirmed recently
  • STALE: not confirmed for a while, but the entry is still there
  • DELAY / PROBE: transitional, a probe is in progress to check the entry
  • FAILED: no reply, the entry is marked unreachable

Linux moves an entry from STALE to REACHABLE on its own when it sees confirming traffic (for example ACK packets from the neighbor).

ARP problems in production

  • Duplicate IP in one network: ARP conflicts, and some hosts log "duplicate address detected" in dmesg
  • Gratuitous ARP during failover (VRRP, keepalived): the new IP owner sends an unsolicited ARP so that switches and neighbors update their tables quickly
  • ARP poisoning: an attacker sends forged ARP replies to intercept traffic. You defend against it with static entries or 802.1x

§ команды

bash
ip neigh

The current ARP/NDP table, what we know about neighbors

bash
ip -s neigh show 192.168.1.20

-s: counters (how many packets went through this entry)

bash
ping -c 1 192.168.1.20 && ip neigh | grep 192.168.1.20

Ping first to populate ARP, then look at the entry

bash
sudo ip neigh flush all

Clear the ARP cache (useful when debugging flapping)

bash
sudo arping -c 3 192.168.1.1

Send an ARP request directly, useful to check L2 connectivity when ICMP is blocked

§ см. также

  • ipv4-addressingIPv4: Addressing and CIDRAn IPv4 address is 32 bits written as `a.b.c.d`. The **/N** suffix is the prefix length: `/24` fixes the first 24 bits for the network and leaves 8 bits for hosts (256 addresses).
  • mac-addressMAC AddressMAC address is a 48-bit hardware identifier for a network interface, written as `aa:bb:cc:dd:ee:ff`. It is unique within an L2 segment and is used in [[ethernet-frame]] for L2 addressing.
  • ethernet-frameEthernet FrameAn Ethernet frame is the L2 transmission unit: dst-MAC, src-MAC, EtherType, payload (usually an IP packet), FCS checksum. Standard MTU is 1500 bytes.
  • broadcast-domainBroadcast Domain: What It Is and Who Lives in ItA group of devices where an L2 frame with dst MAC `FF:FF:FF:FF:FF:FF` (broadcast) reaches everyone. A switch extends a broadcast domain; a router stops it.

§ упоминается в уроках

  • ›intermediate-01-network-101
  • ›intermediate-03-three-node-routing
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies