Skip to content

vde_router: let dhcpd say which DNS server to offer - #83

Open
zirize wants to merge 1 commit into
virtualsquare:masterfrom
zirize:vde_router-dhcpd-dns
Open

zirize wants to merge 1 commit into
virtualsquare:masterfrom
zirize:vde_router-dhcpd-dns

Conversation

@zirize

@zirize zirize commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Authored with Claude Code; I am submitting it. A small follow-up to #75, which
it builds on (it touches the HOWTO added there).

Why

Every DHCP offer vde_router builds carries a DNS server, and the address is a
constant in vder_dhcp.c (OPENDNS, 208.67.222.222). Nothing can change it.

That is the wrong default for most VDE networks. They usually have a resolver
of their own, which is the only thing that knows the names that exist there,
and 208.67.222.222 only answers at all if the router has a working uplink -
which a router serving an isolated segment need not have.

What it does

dhcpd start takes an optional fourth argument:

dhcpd start eth0 10.0.0.20 10.0.0.40 10.0.0.1
  • Left out, the offer carries 208.67.222.222 exactly as before, so existing
    configurations are unaffected.
  • The address is validated the same way the pool bounds are, so a malformed,
    zero, broadcast or multicast address is refused (EINVAL) instead of ending
    up in an offer.
  • The manual page and the HOWTO document the argument, and "advertises a fixed
    public resolver" is dropped from their lists of known limitations.

Verification

On an isolated test segment, with an ASan/UBSan build, a DHCP client checked
the address actually carried in the offer:

  • set from the configuration file → offered as given
  • set from a management-socket dhcpd start → offered as given
  • argument omitted → 208.67.222.222
  • bogus, 0.0.0.0, 255.255.255.255, 224.0.0.1 → refused; the router keeps running

No AddressSanitizer or leak reports; the only UBSan output is the existing
misaligned-access notes in vder_packet.c, unrelated to this change. The
router's existing forwarding/ARP regression tests still pass, and I have been
running this on my own network to hand out a local resolver.

🤖 Generated with Claude Code

Every DHCP offer the router builds carries a DNS server, and its address is a
constant in the file:

	#define OPENDNS (htonl(0xd043dede))
	...
	uint32_t dns_server = OPENDNS;

Nothing can change it.  vder_dhcp.h has carried a DHCP_DNS bit for the settings
flags since the router was written, with no field to go with it and no code
that reads it.

A public resolver is the wrong default for what this router is for.  A VDE
network usually has a resolver of its own, and the hosts on it need to be told
about it, because it is the only thing that knows the names that exist there.
A public resolver does not fail on those names either - it answers with
whatever the registered domain of the same name happens to hold - so a host
that was pointed at a name instead of an address quietly talks to a stranger.
And 208.67.222.222 only answers at all if the router has a working uplink,
which a router serving an isolated segment need not have.

Add dns_server to struct vder_dhcpd_settings and take it as an optional fourth
argument to "dhcpd start":

	dhcpd start eth0 10.0.0.20 10.0.0.40 10.0.0.1

Left out, the offer carries 208.67.222.222 as before.  The address is checked
the same way the pool bounds are, so a multicast or malformed one is refused
instead of ending up in an offer.

The manual page and the HOWTO mentioned the resolver only as a known
limitation ("advertises a fixed public resolver").  Both now document the
argument, and that line is dropped from their limitations.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant