Page MenuHomeVyOS Platform

pdns-recursor crashes on restart if hostfile-update is enabled and dhcp client sends hostname with trailing dot
Closed, ResolvedPublicBUG

Description

Some clients (eg. printers) send a hostname with a trailing dot. Since the kea hook adds the hostname sent by the client verbatim (https://github.com/vyos/vyos-1x/blob/9171b2912a6adbe88de4eeacbcc83cea5c941e48/src/system/on-dhcp-event.sh#L61), the /etc/hosts entry might end up looking like this:

# dhcp-server-10.8.8.34
10.8.8.34       apc-basement..dhcp.chiller3.com

This value is added to recursor.vyos-hostsd.conf.lua verbatim also (https://github.com/vyos/vyos-1x/blob/9171b2912a6adbe88de4eeacbcc83cea5c941e48/data/templates/dns-forwarding/recursor.vyos-hostsd.conf.lua.j2#L8C1-L8C1). The double dots cause pdns-recursor to crash when restarted (or just not update if it's still running).

Jan 15 22:27:34 vyos pdns-recursor[4198]: msg="Encountered error reloading zones, keeping original data" error="Found . in wrong position in DNSName: apc-basement\\.\\.dhcp\\.chiller3\\.com" subsystem="config" level="0" prio="Error" tid="0" ts="1705375654.187"

Can the kea hook script be updated to strip trailing periods? (or some other form of normalization if that's more appropriate?)

Details

Difficulty level
Unknown (require assessment)
Version
1.5-rolling-202401130024
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Unspecified (please specify)

Event Timeline

I am facing same issue here.
In my case, My laptop hostname is cn002472.xxx.com

in recursor.vyos-hostsd.conf.lua :
addNTA("cn002472..", "dhcp-server-10.0.0.106") --> there are double dot here (also in /etc/hosts )which leading powerdns failed to start

Good practise add a set of the commands to reproduce
Thanks

Sure. I did some further testing and it looks like this is triggered if the client sends DHCP option 81 (FQDN). To reproduce:

On the VyOS side:

set service dhcp-server hostfile-update
# Ensure this is *not* set:
#set service dns forwarding ignore-hosts-file

From a Linux client:

sudo dhcpcd -h foobar -F both -4B <interface>

This should result in foobar..<domain> (double dots) being added to /etc/hosts.

Now try restarting pdns-recursor:

restart dns forwarding

systemctl status pdns-recursor will show the process repeatedly crashing due to the double dots.

sarthurdev changed the task status from Open to Needs testing.Jan 17 2024, 5:23 PM
sarthurdev claimed this task.
sarthurdev moved this task from Need Triage to In Progress on the VyOS 1.5 Circinus board.
sarthurdev added a subscriber: sarthurdev.

Tested https://github.com/vyos/vyos-1x/pull/2857 and confirmed that it works properly now. Thanks for the quick fix!

Viacheslav moved this task from In Progress to Finished on the VyOS 1.5 Circinus board.

@chenxiaolong Thanks for confirming!