Skip to content

Names and DNS

Outcome: you can decide, for any watch, whether bandwhich should resolve addresses to names — knowing what the names cost, where they come from, and why a name is a claim and not an identity.

What resolution does

An address like 203.0.113.7 tells you nothing at a glance. The resolver's job is to replace it, where it can, with a name — the machine's hostname as published in the Domain Name System (DNS), the internet's distributed address book. bandwhich does this in the background, on a best-effort basis: the display runs at full speed without waiting, rows show the bare address until an answer arrives, and an address whose lookup fails simply stays an address.

The lab watched it happen on the smallest possible scale (transcript examples/transcripts/t05-raw-dns-on.txt). The same fixture download, run without --no-resolve, produced connection lines like:

connection: <1793870412> <lo>:18090 => localhost.:60016 (tcp) up/down Bps: 847938/0 process: "python3"

The peer 127.0.0.1 had become localhost. — trailing dot and all, exactly as the resolver reported it — while the remote_address: lines kept the numeric address. Resolution arrived a refresh or two after the traffic started; the earliest lines still show the bare address. That lag is normal and worth expecting: a name appearing late is the resolver catching up, not the traffic changing.

The cost, stated plainly

Every name on screen was bought with queries — extra network traffic that bandwhich itself generates, sent to your configured resolver, for every new address it sees. On a quiet machine that is nothing. On a busy one it is a steady stream of lookups, each one also telling the resolver which addresses your machine is talking to. And the answers are only as trustworthy as their source: a reverse name is published by whoever controls the address's DNS zone — the address's owner, in other words. A hostname in bandwhich is a claim the remote side makes about itself. A row can call itself anything its owner configured; the address is the harder fact, and chapter 12 lists this among the limits for a reason.

Switching it off, and aiming it

  • --no-resolve (short form -n) turns resolution off entirely. Every lab capture in raw mode used it, and it is the right default for scripts, logs, and any watch where you will act on the results: what you record is addresses, which do not change their story later.
  • --dns-server <address> aims the lookups at a resolver you choose instead of the system default — useful when the system resolver is the thing under investigation, or when a split network answers internal names only from an internal server. The lab names this flag from the --help text; its captures had no need of it.
  • --show-dns (short form -s) adds the DNS exchanges themselves to what bandwhich displays, so the resolver's own traffic stops being invisible. Also from the documentation: the lab's isolated network had no reachable resolver to exchange with, and the text does not pretend otherwise.

One related expectation to set: on the interactive screen, names can also be truncated by a narrow window — the display is responsive and shows less when there is less room. A suspiciously short name in a small terminal is a layout fact, not a DNS fact. Widen the window, or switch to raw mode, before doubting the resolver.

Check: run the fixture twice, once with -n and once without. The addresses match line for line; only the naming differs, and in the resolving run the names arrive after the traffic does. If you can see that, you understand both what the resolver adds and what it cannot change.