The Scanner That Couldn't See the Server

· nat's blog


This is an AI generated article. I basically did zip/zero to solve this problem. I keep it here for future reference, when my EPSON Network scanner doesn't want to connect to my paperless setup again.

A tale of one ethernet jack, some dead-end mDNS theories, and why foo.local names are weirder than they look.

TL;DR: Our network scanner couldn't find the file server by its usual address. After chasing Docker, the firewall, Samba, Avahi and a chat app through the woods, the answer was embarrassingly physical: the server's network cable had been moved to a second ethernet port. Different port, different MAC address, so the DHCP reservation no longer matched, so the server lost its usual IP — and the scanner spent all day politely knocking on the old one.


The symptom #

The setup: a small Linux box ("peschel") running a Paperless document setup in Docker, which also exports a couple of folders over SMB. An EPSON network scanner is configured to drop scans into \\peschel.local\scan.

One day the scanner just… stopped seeing the server. Everything else worked. Only the scanner was unhappy.

Step 1 — Rule out "the service is down" #

Before blaming anything mysterious, ask the boring question: can another machine on the LAN actually reach the service?

From a second box on the same network:

1nc -zv 192.168.2.11 445     # SMB
2nc -zv 192.168.2.11 139     # SMB (legacy)
3ping -c2 192.168.2.11

All open, all answering. So the SMB server was fine and reachable, which quietly rules out a fat chunk of the usual suspects:

So it wasn't "the server is broken". It was "the scanner and the server disagree about something".


The mDNS rabbit hole (and why *.local is fragile) #

Our first instinct — and where we spent the most time — was that this was an mDNS problem, long before the wire straightened us out. That's partly because .local names really do fail in ways that look identical to "the network is broken", so it's worth writing down what we learned here; it'll come up again.

What's actually going on #

peschel.local isn't DNS — it's mDNS (multicast DNS, RFC 6762), a little peer-to-peer naming system where every machine answers for its own name, no central server involved. It's paired with DNS-SD (RFC 6763), which is the half that publishes services like printers and scanners.

It's also not one flat lookup. A hostname and a service are each published as a small graph of DNS records:

Record Question it answers
A / AAAA "what IPv4 / IPv6 address does this hostname have?"
PTR "what services exist of this type?" (also the reverse-name pointer)
SRV "which host, and which port, does this service run on?"
TXT "what extra key=value metadata does it carry?"

So when the scanner is found, the answer is really "here's an SRV pointing at EPSONF931CE.local:443, plus a TXT blob describing model, duplex and colour" — the friendly list of scanners is just those records rendered.

Two facts cause most of the pain, and both come from "it's just UDP on a shared multicast group":

  1. Any process can grab port 5353. UDP ports have no per-process ownership; a program can bind() 5353 and join the multicast group next to everybody else.
  2. Responders often only answer queries that come from source port 5353. Per the RFC, a query from any other source port is a "one-shot" and may be answered differently — or ignored. That's why a would-be responder is forced to bind 5353 in the first place: it's the only port that reliably gets an answer.

How to probe mDNS #

 1# What does this name resolve to, right now? (IPv4 only — add -6, or omit for both)
 2avahi-resolve -n -4 peschel.local
 3
 4# Browse everything advertised on the LAN (-t = terminate once done)
 5avahi-browse -a -t
 6
 7# Browse *one* service type and print its full records (SRV/TXT/address)
 8avahi-browse -rt _uscans._tcp
 9
10# Who currently owns the mDNS port?
11sudo ss -ulnp | grep 5353
12
13# Watch the actual conversation on the wire
14sudo tcpdump -i enp71s0 -n udp port 5353

That last one is the ground truth. Everything else is a tidy view of the same packets — including the ones being silently dropped.

The Chromium squat: two mDNS stacks on one port #

We didn't just suspect a second responder — we caught it. Restarting Avahi printed:

Detected another IPv4 mDNS stack running on this host

and ss -ulnp | grep 5353 named the culprit: a chat app (Electron — i.e. bundled Chromium) holding 224.0.0.251:5353 with four sockets, right alongside Avahi's 0.0.0.0:5353. Why is that even possible?

Chromium should detect an existing system responder over D-Bus and reuse it; Electron builds frequently ship without that integration. You can suppress the behavior per-app with a --disable-features=MediaRouter flag, but it's worth internalizing that this is a long-standing Chromium-vs-Avahi crowd, not something you broke.

The uncomfortable summary: a chat client can legitimately sit on the same UDP port as your system naming service. "System service" reserves the logic and the config file — not the port.

Why the hostname advertised itself five times (the Docker angle) #

The box runs a Paperless stack under Docker. Docker doesn't keep to itself — it creates a virtual bridge interface on the host for every network it needs:

Each of those bridges gets a host-side gateway address — 172.17.0.1, 172.18.0.1, 192.168.122.1, and so on. And here's the kicker: they're ordinary interfaces as far as Avahi is concerned. Its default is to publish the hostname on every interface it can see, so peschel.local suddenly came back with several answers:

$ avahi-resolve -n -4 peschel.local
peschel.local   172.17.0.1     # ← Docker bridge, unreachable from the LAN (plus 4 more)

A client that grabs the first answer resolves peschel.local to a 172.x address that means nothing outside the host, and then "can't connect". Nothing is actually broken — the name just points at the wrong place.

Two details specific to our setup:

You can see the roster the way Avahi sees it, and correlate it with Docker's own view:

1ip -br addr                                   # every interface + its addresses
2docker network ls                            # one network per br-<hash> above
3avahi-browse -art | grep -E 'docker0|br-[0-9a-f]+|virbr0|vnet[0-9]+'

Worth noting the leak grows on its own: each docker compose up that (re)creates a network mints a fresh br-<hash> with a fresh 172.x.0.1 gateway, and Avahi dutifully starts advertising the hostname on it too. That's why "it used to be fine" — there are simply more bridges than there used to be.

How to stop it #

Tell Avahi to only serve the interfaces you actually care about:

1# /etc/avahi/avahi-daemon.conf
2[server]
3allow-interfaces=enp71s0,enp69s0

then:

1sudo systemctl restart avahi-daemon
2avahi-resolve -n -4 peschel.local    # back to exactly one, correct address

Prefer allow-interfaces= over deny-interfaces=. A deny-list looks tempting (deny-interfaces=docker0,virbr0,…) but the br-<hash> names change every time a Compose network is recreated, so the list quietly rots. Allow-listing your real NICs is stable.

Confirm it took with the same avahi-browse -art | grep … query from above — no output means nothing virtual is being advertised any more. You can also watch Avahi pick its interfaces as it starts:

1journalctl -u avahi-daemon --since "1 min ago" | grep -E 'Joining mDNS|New relevant'
2# should list only enp71s0 / enp69s0, never docker0 / br-* / virbr0

(Heads-up: an avahi package upgrade can reset that config file — if .local ever resolves to a 172.x again, check this line first.)

Why it's a system service (and why .local is a special zone) #

Avahi owns the host's identity, so it's naturally one process for the whole box rather than one per user — and it also becomes the thing every program resolves through. That second part happens via NSS: /etc/nsswitch.conf carries a hosts: line like

hosts: files mdns4_minimal [NOTFOUND=return] dns

which means a plain getent hosts peschel.local — or any ping/browser — routes .local lookups through the libnss-mdns bridge, which then asks Avahi over D-Bus. That's why the system knows the name even though no DNS server does:

1getent hosts peschel.local     # goes through NSS → libnss-mdns → Avahi

Two more wrinkles worth knowing:

Probing from a second host #

Half of "proving" a network problem is doing it from somewhere else. Borrowing a second machine:

1nc -zv <target-ip> 445          # is the port reachable at all?
2ping -c2 <target-ip>
3sudo tcpdump -i eth0 -n udp port 5353   # what's actually on the wire?

If a raw multicast listener sees nothing, remember two gotchas: you must join the multicast group to receive, and on multi-homed boxes the kernel loves to send multicast out the wrong interface (check ip route get 224.0.0.251).


Step 2 — Watch the wire #

Eventually we stopped theorising and did the one thing that actually settles network arguments: look at the packets. Capture everything the scanner does:

1sudo tcpdump -i enp71s0 -n -l '(host 192.168.2.217 or udp port 5353 or arp)'

(Replace the interface and the scanner's IP with yours.)

What came back was the money shot. The scanner wasn't failing to discover the server — it was hammering a specific, hard-coded-looking IP that nobody owned:

ARP, Request who-has 192.168.2.11 tell 192.168.2.217
ARP, Request who-has 192.168.2.11 tell 192.168.2.217
ARP, Request who-has 192.168.2.11 tell 192.168.2.217   ...

About once a second, forever, with no reply. Check the local neighbor table and you see the same sad story:

1ip neigh | grep 192.168.2.11
2# 192.168.2.11 dev enp71s0  INCOMPLETE

INCOMPLETE = "I asked who has this IP and nobody answered." The scanner was talking to a ghost.

Step 3 — The real clue was a MAC address #

We knew 192.168.2.11 was the server's usual address. So why didn't it have it?

The network's DHCP server (dnsmasq, /etc/dnsmasq.d/local.conf) had a reservation pinning that name to that IP:

1dhcp-host=a8:a1:59:99:35:49,peschel,192.168.2.11,24h

Read that carefully: the reservation is keyed to a MAC address ending ...49. But the machine's active adapter had a different MAC:

1ip -o link show
2cat /sys/class/net/*/address
enp71s0   a8:a1:59:99:35:49   carrier=0   ← reserved for .32, cable unplugged
enp69s0   a8:a1:59:99:35:4b   carrier=1   ← cable plugged in here

Two network ports, one cable. Someone had moved the cable from the Intel port (...49) to the Realtek port (...4b). A different port means a different MAC address, which means the DHCP reservation no longer matched, which means the machine quietly fell back to whatever the DHCP pool offered — 192.168.2.101 instead of .32.

The scanner, meanwhile, still believed the server lived at .32. It had been completely correct all along, just pointed at an address that no longer existed.

The fix: move the cable back to the original port. Scan works. The end.


Lessons (mostly for future-us) #