1 # $NetBSD: 29-lookup-hostname,v 1.7 2014/12/09 20:21:05 roy Exp $
3 # Lookup the hostname in DNS if not set
7 [ -z "$new_ip_address" ] && return 1
9 # Silly ISC programs love to send error text to stdout
10 if type dig >/dev/null 2>&1; then
11 h=$(dig +short -x $new_ip_address)
13 echo "$h" | sed 's/\.$//'
16 elif type host >/dev/null 2>&1; then
17 h=$(host $new_ip_address)
20 | sed 's/.* domain name pointer \(.*\)./\1/'
23 elif type getent >/dev/null 2>&1; then
24 h=$(getent hosts $new_ip_address)
26 echo "$h" | sed 's/[^ ]* *\([^ ]*\).*/\1/'
35 if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
36 export new_host_name="$(lookup_hostname)"