Wrong Device Answers Your IP? How to Find a Duplicate IP Address with ARP
You type in your NAS's address, and the printer's admin page comes up. Nothing on the NAS changed. Let's find out who is answering at that address, and why.
A homelab on one switch: a PC, a NAS that serves the family photos, and a new printer. Each device is its own container. Someone set the printer up by hand, and now two devices answer for the same address.
The lab
Here is the lab: a PC, the NAS and a new printer, all on one switch and one network. The NAS is 10.0.10.30. Every network card also has a MAC address, its hardware address on the local network. The PC's ends in 20, the NAS's in 30, and the printer's in 99. Keep those three endings in mind.
The symptom
curl -s http://10.0.10.30
<!doctype html> <title>printer</title> <h1>Printer admin: toner low</h1> <p>Served by the printer.</p>
What this shows
From the PC, curl asks the NAS's address for its web page. What comes back is the printer's admin page: toner low. The address is right, but the device on the other end is the printer.
Narrowing it down
ping -c 3 10.0.10.30
PING 10.0.10.30 (10.0.10.30) 56(84) bytes of data. 64 bytes from 10.0.10.30: icmp_seq=1 ttl=64 time=0.040 ms 64 bytes from 10.0.10.30: icmp_seq=2 ttl=64 time=0.038 ms 64 bytes from 10.0.10.30: icmp_seq=3 ttl=64 time=0.034 ms --- 10.0.10.30 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2050ms rtt min/avg/max/mdev = 0.034/0.037/0.040/0.002 ms
What this shows
Ping gets three replies out of three. So something is answering at 10.0.10.30. Ping can't tell us which device it is, only that one replied.
ip neigh
10.0.10.30 dev eth1 lladdr 02:00:00:00:00:99 REACHABLE
What this shows
On a local network, the PC finds a device by its MAC address. It learns that address with ARP, and keeps it in its ARP cache. ip neigh shows the whole cache, and right now it holds one entry: 10.0.10.30, at the MAC address ending in 99.
ip -br link show eth1
eth1@if1357 UP 02:00:00:00:00:30 <BROADCAST,MULTICAST,UP,LOWER_UP>
What this shows
On the NAS itself, ip link shows its own MAC address. It ends in 30, not 99. So the PC is sending the NAS's traffic to a different device.
arping -b -c 2 -I eth1 10.0.10.30
ARPING 10.0.10.30 from 10.0.10.20 eth1 Unicast reply from 10.0.10.30 [02:00:00:00:00:99] 0.545ms Unicast reply from 10.0.10.30 [02:00:00:00:00:30] 0.557ms Unicast reply from 10.0.10.30 [02:00:00:00:00:99] 0.531ms Unicast reply from 10.0.10.30 [02:00:00:00:00:30] 0.554ms Sent 2 probes (2 broadcast(s)) Received 4 response(s)
What this shows
arping sends the ARP question itself, who has 10.0.10.30, and prints every answer. Two questions, four answers. Each time, one comes from the MAC ending in 99, and one from the MAC ending in 30. Two devices claim the same address.
Finding the cause
bridge fdb show br br0 | grep -v permanent
02:00:00:00:00:20 dev eth1 master br0 02:00:00:00:00:99 dev eth3 master br0 02:00:00:00:00:30 dev eth2 master br0
What this shows
To find the device behind 99, ask the switch. Its MAC table records which port each MAC address was seen on. Ending in 20 is on eth1, the PC. Ending in 30 is on eth2, the NAS. Ending in 99 is on eth3, and eth3 is the printer's port.
ip -br addr show eth1
eth1@if1355 UP 10.0.10.30/24 fe80::ff:fe00:99/64
What this shows
On the printer, ip addr shows its address: 10.0.10.30 slash 24. The new printer was set up with the NAS's address.
The fix
ip addr del 10.0.10.30/24 dev eth1
(no output)
What this shows
The fix is to give the printer an address of its own. First, take the NAS's address off it.
ip addr add 10.0.10.40/24 dev eth1
(no output)
What this shows
Then give it 10.0.10.40, which nothing else is using.
ip -br addr show eth1
eth1@if1355 UP 10.0.10.40/24 fe80::ff:fe00:99/64
What this shows
The printer now has 10.0.10.40, and only that.
ip neigh flush dev eth1
(no output)
What this shows
The PC may still remember the printer's MAC for 10.0.10.30. ip neigh flush clears the PC's ARP cache, so it has to ask again.
arping -b -c 2 -I eth1 10.0.10.30
ARPING 10.0.10.30 from 10.0.10.20 eth1 Unicast reply from 10.0.10.30 [02:00:00:00:00:30] 0.530ms Unicast reply from 10.0.10.30 [02:00:00:00:00:30] 0.531ms Sent 2 probes (2 broadcast(s)) Received 2 response(s)
What this shows
The same arping as before. Two questions, two answers this time, both from the MAC ending in 30: the NAS.
curl -s http://10.0.10.30
<!doctype html> <title>nas.homelab.test</title> <h1>NAS: family photos</h1> <p>Served by the NAS, 10.0.10.30.</p>
What this shows
The NAS's address opens the NAS's page again: family photos.
curl -s http://10.0.10.40
<!doctype html> <title>printer</title> <h1>Printer admin: toner low</h1> <p>Served by the printer.</p>
What this shows
And the printer's admin page is at its own address, 10.0.10.40.
Why it happened
So why did the printer win? ARP has no idea which device is the rightful owner of an address. The PC asks who has it, and keeps the answer it gets. With two devices answering, the cache holds whichever answer it last believed, and that can change from minute to minute. That's why a duplicate address often looks like a device that works, then doesn't. Giving every device its own address, or a DHCP reservation, keeps answers to one.
When an address seems to belong to two devices at once, ask ARP. arping shows every device that answers, and the switch's MAC table shows where each one is plugged in.
Try it yourself
The whole lab runs on your own computer with Docker and containerlab: get it on GitHub, then ./lab.sh up and ./lab.sh break. Setup steps are on Run the labs.