/usr/share/dhcpcd/hooks/29-lookup-hostname is in dhcpcd5 6.10.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  | # Lookup the hostname in DNS if not set
lookup_hostname()
{
	[ -z "$new_ip_address" ] && return 1
	local h=
	# Silly ISC programs love to send error text to stdout
	if type dig >/dev/null 2>&1; then
		h=$(dig +short -x $new_ip_address)
		if [ $? = 0 ]; then
			echo "$h" | sed 's/\.$//'
			return 0
		fi
	elif type host >/dev/null 2>&1; then
		h=$(host $new_ip_address)
		if [ $? = 0 ]; then 
			echo "$h" \
			| sed 's/.* domain name pointer \(.*\)./\1/'
			return 0
		fi
	elif type getent >/dev/null 2>&1; then
		h=$(getent hosts $new_ip_address)
		if [ $? = 0 ]; then
			echo "$h" | sed 's/[^ ]* *\([^ ]*\).*/\1/'
			return 0
		 fi
	fi
	return 1
}
set_hostname()
{
	if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
		export new_host_name="$(lookup_hostname)"
	fi
}
if $if_up; then
	set_hostname
fi
 |