DevBackend TechHub
DevBackend TechHub

ARP Command Guide: Syntax, Troubleshooting & Security

Master the arp command for Windows, Linux, and macOS. Learn syntax, flush cache, prevent spoofing, and fix network errors with our expert guide.

#Network#Errors debugging

You can ping the gateway, but the connection fails after 30 seconds. Is it a firewall issue, or is it a corrupted ARP cache? If you’ve ever stared at a "Destination Host Unreachable" error while your network link looks green, you know the frustration. The answer often lies in the arp command, a deceptively simple tool that maps IP addresses to mac address identifiers on your local segment. Without a correct mapping in the ARP table, your device literally cannot build the Ethernet frame to send data to the next hop.

For the next few minutes, we’re going to move beyond the syntax. We’ll look at why arp behaves differently on Windows versus modern Linux, how to spot when an attacker is trying to poison your cache, and when it’s worth locking a static entry in place. I’ve spent the last decade debugging network segmentation issues, and I can tell you: 80% of "intermittent connectivity" bugs on a LAN are ARP ghosts haunting your cache.

Detailed close-up of ethernet cables and network connections on a router, showcasing modern technology.

Core Syntax: Using the ARP Command in Windows

Windows has kept the arp utility as a stable, first-class citizen of the Command Prompt (cmd) and PowerShell for decades. While other platforms are migrating to more complex utilities, the Windows version remains consistent and predictable.

Viewing and Filtering the ARP Table

The most basic interaction is checking who is on your wire. To list all interfaces, you simply run arp -a. However, on a machine with multiple network cards—say, a dedicated NIC for lab traffic and another for your office VLAN—the output can get noisy.

In my experience, filtering by interface saves a lot of scrolling. You can target a specific NIC by specifying its IP address using the -N flag.

arp -a -N 192.168.1.5

One detail often missed by beginners: the "Type" column. When you see an entry marked as "static," you know an admin (or a script) pinned it. When it says "dynamic," it’s resolved automatically. But the scary one is "incomplete."

If you run arp -a and see an IP address with a MAC of 00-00-00-00-00-00 and the type as "incomplete," it means your machine sent an ARP request, but no one answered. This usually happens when the target device is powered off, its cable is bad, or its firewall is dropping ARP replies (rare, but possible). It’s not that the entry is "wrong"; it’s that the entry is empty.

Adding and Deleting Static ARP Entries

Sometimes, you need to stop guessing. If you’re dealing with a flaky printer or a critical server on a busy segment, you can force the mapping. The syntax to add a static entry is straightforward, but note that Windows requires the MAC address in hyphenated hex format, not colons.

To delete a specific entry and force a re-resolution, use the -d flag:

arp -d 10.0.0.1

To add a static entry, use -s. For example, to pin the gateway 10.0.0.1 to a known MAC:

arp -s 10.0.0.1 00-AA-00-4F-2A-9C

Here’s the catch that trips up many admins: Windows static ARP entries are temporary. They last until the TCP/IP stack restarts or the machine reboots. They do not persist. If you need permanence, you have to script this. I usually create a simple batch file that runs these arp -s commands and schedule it via Task Scheduler to run at startup. It’s old-school, but it works reliably.

Close-up of a hand holding a tech-themed sticker with a home symbol and numbers.

Linux & macOS: Beyond Legacy ARP to Modern Networking

Linux has a complicated relationship with the arp command. It used to be king, but the iproute2 suite (specifically the ip command) has largely superseded it in modern distributions like Ubuntu, CentOS, and Debian.

Why 'ip neigh' Replaces 'arp' in Modern Linux

If you’re used to Windows, typing arp -a on an Ubuntu terminal might fail or give you a warning that the tool is deprecated. This is because the legacy arp utility talks to an older kernel interface. The modern standard is ip neigh (short for neighbor).

Why the change? ip neigh handles not just Ethernet, but also IEEE 802.154, InfiniBand, and other link-layer technologies. It’s more granular.

Here’s a quick side-by-side to help you translate your muscle memory:

ActionLegacy Linux (arp)Modern Linux (ip)
Show all entriesarp -nip neigh show
Delete specific IParp -d <ip>ip neigh del <ip>
Flush entire cachearp -d * (varies by distro)ip neigh flush all
Add static entryarp -s <ip> <mac>ip neigh add <ip> lladdr <mac> dev <iface>
I’ve found that on CentOS and RHEL systems, the arp command still works fine for quick checks, but ip neigh gives you state information (like STALE or REACHABLE) that the legacy tool hides. That state information is gold when debugging why a connection is dropping.

Cache Flushing on Linux and macOS

When troubleshooting, flushing the cache is often step one. You’re forcing the system to re-ask the network who owns the IP addresses it wants to talk to.

On Linux, the nuclear option is:

sudo ip neigh flush all

If you only want to nuke one specific IP because you think it’s been spoofed or moved:

sudo ip neigh del 192.168.1.100

On macOS, Apple stays closer to the Unix heritage. The ip command suite isn’t as central as it is on Linux, so you stick with arp. To delete an entry:

sudo arp -d 192.168.1.1

To flush everything, you often have to iterate through the existing entries or use a script, as arp -d * isn’t always supported the same way across all Unix variants. A common workaround on Mac is using sudo -s /sbin/arp -d in a loop, but usually, deleting the specific problematic IP is safer and faster.

Security: Detecting Spoofing & Poisoning Threats

This is the section most "cheat sheet" articles skip, but it’s where the arp command becomes a security tool, not just a debugging one. Because ARP operates at Layer 2 (Data Link), it has no authentication. An attacker on the same subnet can broadcast fake ARP replies, convincing your router (or your PC) that they are the gateway. This is ARP spoofing.

Identifying Anomalies in Your ARP Cache

How do you spot it? You watch for inconsistencies. If your gateway IP 192.168.1.1 suddenly has a different MAC address than it did five minutes ago, and you didn’t change your router, you have a problem.

I recommend running this periodically on critical hosts:

arp -a

Look for duplicate IPs mapping to different MACs. In a clean environment, one IP = one MAC. If you see 192.168.1.1 pointing to AA:BB:... and also to CC:DD:..., one of them is lying. To help the system prefer the correct one, you can use a static entry to "pin" the legitimate gateway.

Using arp -s (on Windows) or ip neigh add ... lladdr ... (on Linux) creates a "Permanent" entry. While a dynamic entry can be overwritten by a newer ARP reply, a static/permanent entry resists this. It’s a blunt instrument, but it’s effective for protecting critical paths.

Static ARP Entries as a Security Measure

For high-security environments, I don’t rely on dynamic ARP at all for core infrastructure. Here is the checklist I use for critical servers:

  1. Identify the Gateway and Critical Peers: Know the MACs of your router, primary DNS, and backup servers.
  2. Apply Static Entries: Push these configurations via script. On Linux, you can add these to /etc/NetworkManager/dispatcher.d/ or your systemd service files to ensure they apply on boot.
  3. Monitor for Changes: Set up a cron job that runs ip neigh (or arp -a) and diffs the output. If a static entry gets overwritten or a new dynamic entry appears for a critical IP, trigger an alert.

This prevents Man-in-The-Middle (MITM) attacks on that specific host. It doesn’t secure the whole network, but it stops the most common off-the-shelf ARP poisoning attacks from affecting your critical communications.

Troubleshooting: When the Cache Won't Update

Sometimes, you’ve flushed the cache, the cable is good, the switch port is up, but you still can’t reach a device. This is where the network interface configuration comes into play.

Diagnosing 'Network Unreachable' Errors

I use a specific decision tree when ping fails but arp shows nothing:

  1. Check the Layer: Is the interface UP? ip link show (Linux) or ipconfig /all (Windows).
  2. Check the ARP: Run arp -a / ip neigh. Do you see the target IP?
    • If No: Your ARP request is likely being blocked or not reaching the destination.
    • If Yes, but Ping Fails: The ARP resolved, but TCP/IP failed. This points to firewalls or routing issues, not Layer 2.
  3. Check for Conflicts: A common, nasty bug is a MAC address conflict. If two devices on a switch port have the same MAC (often happens with cloned VMs), the switch may discard frames, causing ARP to fail or return "incomplete" status.

In one case I handled, a user had a "permanent" static ARP entry for a server that had just been replaced with a new NIC. The old static entry was blocking the new MAC from resolving. The fix wasn’t adding a new entry; it was deleting the stale static one (arp -d or ip neigh del) to allow the system to learn the new MAC address.

Quick Reference: The ARP Command Cheat Sheet

For those who need to jump in and fix something right now, here is the unified reference. Keep this in your favorite text file.

Command Summary Table

ActionWindows (cmd)Linux (Modern ip)macOS
View Allarp -aip neigh showarp -a
View Specific IParp -a <IP>ip neigh show <IP>arp -a <IP>
Delete Specific IParp -d <IP>ip neigh del <IP>sudo arp -d <IP>
Add Static Entryarp -s <IP> <MAC>ip neigh add <IP> lladdr <MAC> dev <IF>sudo arp -s <IP> <MAC>
Flush Cachearp -d *ip neigh flush allsudo arp -d (loop)
Note: On Windows, MACs use hyphens (AA-BB-CC), while Linux/macOS use colons (AA:BB:CC).

FAQ

What is the difference between ARP and DNS commands? Think of it this way: DNS is the phone book. It tells you google.com is 8.8.8.8. That’s Layer 7. ARP is the street address. Once you know the IP is 8.8.8.8, ARP tells your network card that this IP lives at MAC AA:BB:CC:DD:EE:FF so you can actually physically wire the packet to it. ARP is strictly local network; it does not traverse routers (in standard configurations).

How do I find my MAC address using the ARP command? You can’t. The arp command maps other IPs to MACs. It does not list your own MAC address. To find your own hardware identifier, use ipconfig /all on Windows or ifconfig / ip link on Linux/macOS.

Why does 'arp -a' show 'incomplete' entries in Windows? An "incomplete" entry means your computer asked, "Who has this IP?" and got no answer within the timeout period. The most common causes are: the target device is off, the physical cable is broken, or the target device is on a different subnet (and your ARP request is being broadcast to a segment that doesn't contain that IP). It is not a failure of the ARP command itself; it’s a report of a network silence.

Conclusion

The arp command is more than a syntax reference; it’s a lens into the health of your Layer 2 connectivity. Before you blame the ISP, the firewall, or the hardware, check the cache. A stale or spoofed entry can make a healthy network look broken.

While the legacy arp tool is fading into obscurity on some Linux distros in favor of ip neigh, it remains the standard on Windows and macOS. Mastering the differences—knowing when to flush, when to pin a static entry, and how to spot a duplicate MAC—will save you hours of head-scratching.

Want to go deeper? Check out our guide on 'Ping vs Traceroute' to understand how these two diagnostics complement each other, or download our printable 'Network Debugging Cheatsheet' for your next on-site visit.

Related Posts