8.2.34 | Linux | www-data (uid:33)
👁 View: 29-lookup-hostname
📁 /snap/core24/2124/usr/share/dhcpcd/hooks/29-lookup-hostname
# Lookup the hostname in DNS if not set lookup_hostname() { [ -z "$new_ip_address" ] && return 1 # Silly ISC programs love to send error text to stdout if command -v dig >/dev/null 2>&1; then h=$(dig +short -x $new_ip_address) if [ $? = 0 ]; then echo "$h" | sed 's/\.$//' return 0 fi elif command -v 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 command -v 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}${new_fqdn_name}" ]; then export new_host_name="$(lookup_hostname)" fi } if $if_up; then set_hostname fi
← Back
💻 Terminal
📤 Upload
📂
Click or Drag & Drop
📁 /snap/core24/2124/usr/share/dhcpcd/hooks
NameSizePermModifiedActions
10-wpa_supplicant2.8K06442025-11-13 17:47👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
15-timezone885B06442025-11-13 17:47👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del
29-lookup-hostname814B06442025-11-13 17:47👁 View ✏️ Edit 📝 Rename 📦 Move 🗑 Del