Sub topic 10
Looking at MAC addresses and neighbor tables on your machine
This chapter assumes you know what a MAC address is, how ARP maps an IPv4 address to a MAC address, and how to read hexadecimal. It also assumes you can run commands in a terminal. Here you will read your own machine's MAC addresses and neighbor table, interpret what you see, and spot the common mistakes.
What you can inspect
Your operating system keeps two pieces of link-layer state that are worth looking at.
- Interface addresses. Each network interface has a MAC address, a state (up or down), and an MTU (maximum frame payload size).
- The neighbor table. This is a cache of IP-to-MAC mappings the host has learned recently. It is filled by ARP for IPv4 and by Neighbor Discovery for IPv6. Many tools still call it the "ARP cache" or "ARP table".
The neighbor table only holds hosts on your own LAN. Remote hosts never appear in it. For a destination across a router, the table holds the entry for the router, not the destination. The next section shows this.
Reading interface MAC addresses on Linux
The ip link show command lists every interface and its link-layer address.
ip link showTypical output looks like this:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ffRead it in pieces:
eth0is the interface name. Names such asenp3s0orwlp2s0are also common, because systemd derives them from the hardware location.- The flags in angle brackets describe capabilities and state.
BROADCASTandMULTICASTmean the interface can send to those group addresses.UPmeans an administrator enabled it.LOWER_UPmeans a physical link (a cable or Wi-Fi association) is present. state UPis the operational state. An interface can beUPin its flags butstate DOWNif no cable is plugged in.link/ether 52:54:00:12:34:56is the MAC address.brd ff:ff:ff:ff:ff:ffis the broadcast address for the link.
The loopback interface has an all-zero MAC address because it never leaves the host. Do not treat it as a real hardware address.
To print one interface in a compact form, use the brief option:
ip -br link showBrief output has one line per interface with the name, state, and MAC address. It is convenient for scripts and for quick comparison.
Reading the address bits
You can apply what you learned about the first octet. In 52:54:00:12:34:56, the first octet is 0x52, which is 01010010 in binary.
- The least significant bit is 0, so the address is unicast.
- The next bit is 1, so the address is locally administered, not assigned by a manufacturer.
That is typical of a virtual machine. QEMU/KVM guests commonly use the 52:54:00 prefix. If you see a locally administered bit on a physical interface, suspect a virtual interface, a container bridge, or a randomized Wi-Fi address.
The Python function below decodes a MAC address into its parts. Run it on any address you collect.
def describe_mac(mac: str) -> dict:
parts = mac.replace('-', ':').split(':')
if len(parts) != 6:
raise ValueError('a MAC address has 6 octets')
octets = bytes(int(p, 16) for p in parts)
first = octets[0]
return {
'oui': ':'.join(f'{b:02x}' for b in octets[:3]),
'device_part': ':'.join(f'{b:02x}' for b in octets[3:]),
'is_group': bool(first & 0x01),
'is_locally_administered': bool(first & 0x02),
'is_broadcast': octets == b'\xff' * 6,
}
print(describe_mac('02:00:5e:10:00:01'))
print(describe_mac('ff:ff:ff:ff:ff:ff'))The first call reports a unicast, locally administered address. The second reports a broadcast address, which also has the group bit set.
Reading interface addresses on other systems
The commands differ by platform, but the information is the same.
| System | Command | Where the MAC appears |
|---|---|---|
| Linux | `ip link show` | `link/ether` |
| macOS | `ifconfig en0` | `ether` |
| Windows | `ipconfig /all` | `Physical Address`, written with hyphens |
| Windows (PowerShell) | `Get-NetAdapter` | `MacAddress` |
Windows writes octets separated by hyphens (52-54-00-12-34-56), while Linux and macOS use colons. Some vendor tools use dotted groups of four digits (5254.0012.3456). The describe_mac function above accepts hyphens and colons but not the dotted form, so normalize first if you paste from a switch.
The older ifconfig command still exists on many Linux systems, but it comes from the net-tools package, which is deprecated. Prefer ip.
Reading the neighbor table on Linux
The ip neigh show command lists the IP-to-MAC entries your host has learned.
ip neigh showExample output:
192.168.1.1 dev eth0 lladdr 3c:84:6a:aa:bb:cc REACHABLE
192.168.1.20 dev eth0 lladdr b8:27:eb:11:22:33 STALE
192.168.1.45 dev eth0 FAILED
fe80::3e84:6aff:feaa:bbcc dev eth0 lladdr 3c:84:6a:aa:bb:cc router REACHABLEEach line has the following parts:
- The IP address of the neighbor.
dev eth0, the interface the entry belongs to.lladdr, the link-layer (MAC) address.- The entry state.
- For IPv6, a
routerflag when the neighbor advertised itself as a router.
The last line shows that one physical device, here the router, appears twice: once with an IPv4 address and once with an IPv6 link-local address. Both map to the same MAC address. The tool shows IPv4 and IPv6 entries together because the kernel stores them in the same neighbor subsystem.
Neighbor states
Linux tracks how fresh each entry is. The state tells you whether the host currently trusts the mapping.
| State | Meaning |
|---|---|
| `REACHABLE` | The mapping was confirmed recently, within the reachable time (a randomized value around 30 seconds by default). |
| `STALE` | The mapping exists but has not been confirmed recently. The kernel keeps using it and verifies it only when traffic needs it. |
| `DELAY` | The kernel just used a stale entry and is waiting briefly for upper-layer evidence (such as a TCP acknowledgment) before probing. |
| `PROBE` | The kernel is sending unicast ARP or Neighbor Solicitation requests to re-confirm the mapping. |
| `INCOMPLETE` | A request has been sent and no reply has arrived yet. |
| `FAILED` | Resolution gave up after retrying. The host could not find a MAC address. |
| `PERMANENT` | An administrator added the entry by hand. It never expires. |
A state diagram shows how an entry moves between these states.
STALE does not mean broken. A quiet LAN full of working neighbors will show mostly STALE entries, because nothing has needed them lately. Only FAILED and long-lived INCOMPLETE entries point to a problem.
Reading the table on macOS and Windows
On macOS and Windows, the classic command is arp.
arp -aThe output lists IP addresses and the MAC address for each, for example ? (192.168.1.1) at 3c:84:6a:aa:bb:cc on en0 ifscope [ethernet] on macOS. On Windows, entries are marked dynamic (learned) or static (added by hand).
For IPv6 neighbors, use ndp -an on macOS and Get-NetNeighbor or netsh interface ipv6 show neighbors on Windows.
On Linux, the older arp -n command also works if net-tools is installed, but it shows IPv4 only. Use ip neigh to see both families.
Triggering and watching resolution
You can watch the table fill. First look at the current entries, then contact a host on your LAN, then look again.
ip neigh show
ping -c 1 192.168.1.20
ip neigh show 192.168.1.20Replace 192.168.1.20 with a real address on your network. If the host had no entry, the first ping triggers an ARP request. Afterward the entry appears as REACHABLE.
Now try a destination outside your LAN, such as a public DNS server:
ping -c 1 1.1.1.1
ip neigh show
ip route get 1.1.1.1No entry for 1.1.1.1 appears. The route lookup shows via 192.168.1.1, your default gateway, and the neighbor table contains the gateway's MAC address. This matches the rule from the previous chapter: the frame's destination MAC is the next hop's address, and the IP destination stays the remote host.
To watch the ARP traffic itself, capture on the interface. This needs root privileges.
sudo tcpdump -n -e -i eth0 arpThe -e option prints the link-layer header. You will see lines such as ethertype ARP (0x0806) with the broadcast destination ff:ff:ff:ff:ff:ff on requests and a unicast destination on replies.
Managing entries by hand
You can edit the table with root privileges. These operations are useful for testing and troubleshooting.
# Delete a single entry so the next packet triggers fresh resolution
sudo ip neigh del 192.168.1.20 dev eth0
# Remove all entries on an interface
sudo ip neigh flush dev eth0
# Add a permanent static entry
sudo ip neigh add 192.168.1.50 lladdr 02:00:00:00:00:50 dev eth0 nud permanentFlushing is safe. The host relearns what it needs the next time it sends a packet. A permanent entry is risky, because it never updates. If the real device later changes its NIC or the IP is reassigned, your host keeps sending frames to the old MAC address and the connection silently fails.
Common errors and how to read them
- Looking for a remote host in the table. Remote hosts never appear. Look for the gateway instead.
- Treating
STALEas a fault. It is a normal idle state. FAILEDorINCOMPLETEfor an address on your subnet. Nobody answered the ARP request. The host may be off, on a different VLAN, behind a firewall that drops ARP, or the address may be wrong. Check that the IP is inside your subnet mask.- One MAC address shown for many IP addresses. This is often normal. A router, a virtualization host, or a device doing proxy ARP answers on behalf of several addresses. It can also indicate ARP spoofing, so check the pattern before concluding either way.
- A MAC address that keeps changing for the same IP. A DHCP lease may have moved, or a failover pair may be exchanging a shared address. If neither explains it, investigate.
- Reading a randomized Wi-Fi address as the "real" one. Modern phones and laptops may use a different address per network. The address you see in the table can differ from the one printed on the device.
- Assuming
ip linkshows the hardware address. It shows the address currently configured, which software can change. The permanent hardware address, when available, appears withethtool -P eth0.
Looking up the vendor
The first three octets are the OUI. You can match an OUI against the public IEEE registry to find the vendor of a physical interface. Many systems ship a local copy; otherwise download the list from the IEEE Registration Authority. This works only for universally administered addresses. If the locally administered bit is set, the OUI does not name a manufacturer, so a lookup gives meaningless or misleading results.
Putting it together
The following script reads the neighbor table on Linux and decodes each MAC address with the same bit rules. It uses only the standard library.
import subprocess
def decode(mac: str) -> str:
first = int(mac.split(':')[0], 16)
kind = 'multicast' if first & 0x01 else 'unicast'
admin = 'local' if first & 0x02 else 'universal'
return f'{kind}, {admin}'
out = subprocess.run(['ip', 'neigh', 'show'], capture_output=True, text=True, check=True).stdout
for line in out.splitlines():
fields = line.split()
if 'lladdr' in fields:
mac = fields[fields.index('lladdr') + 1]
print(f'{fields[0]:<40} {mac} {decode(mac)} {fields[-1]}')Lines with no lladdr, such as FAILED entries, are skipped because there is no MAC address to decode. Run the script on a home network and you will likely see a mix of universal addresses (routers, printers) and local ones (phones using randomization, virtual machines).
Exercise
On a Linux host with the address 192.168.1.10/24 and the default gateway 192.168.1.1, you run ping -c 1 8.8.8.8 and then ip neigh show. Which IP address's entry do you expect to see, and why? What does a STALE state on that entry mean?
Show answer
You expect an entry for 192.168.1.1, the gateway, and no entry for 8.8.8.8. The destination is outside the subnet, so the host sends the frame to the next hop, and it needs the gateway's MAC address as the frame's destination MAC. The IP packet still carries 8.8.8.8 as its destination. A STALE state means the mapping was learned earlier but has not been confirmed recently. The host still uses it, and it re-verifies it only when new traffic needs it. It is not an error.
Exercise
The command ip link show prints link/ether 02:1a:2b:3c:4d:5e for a physical Wi-Fi interface on a laptop. What do the first octet's bits tell you, and why should you avoid looking up the OUI?
Show answer
The first octet is 0x02, which is 00000010 in binary. The least significant bit is 0, so the address is unicast. The next bit is 1, so the address is locally administered. A locally administered address was not assigned by a manufacturer, so the OUI does not identify a vendor. On a Wi-Fi interface this is a typical sign of MAC randomization, and a vendor lookup would give no useful answer.