How can i make hostname
(i.e. the unix commandline tool hostname
, invoked in terminal) return a hostname including the domain information?
At the moment, hostname
, hostname -f
and hostname -s
return the same name, all without the domain information, but host <hostname>
returns the full hostname:
$ hostname
> jvf-imac
$ hostname -f
> jvf-imac
$ hostname -s
> jvf-imac
$ host jvf-imac
> jvf-imac.fritz.box has address 192.168.178.31
The question is not about how I can get the full hostname in general. Some scripts I use rely on hostname -f
to get the fully qualified hostname, so I need to make hostname -f
return the correct hostname. Anyone any idea?
Updates
System Overview
- System Version: OS X 10.10.5 (14F27)
- Kernel Version: Darwin 14.5.0
- Computer Name: jvf_imac
Content of resolv.conf (shortened)
domain fritz.box
nameserver 192.168.178.1
DNS Setup (shortened)
$ scutil --dns
resolver #1
search domain[0] : fritz.box
nameserver[0] : 192.168.178.1
if_index : 4 (en0)
flags : Request A records
reach : Reachable,Directly Reachable Address
resolver #2
domain : local
options : mdns
timeout : 5
flags : Request A records
order : 300000
resolver #3
domain : 254.169.in-addr.arpa ...
...
resolver #7
domain : b.e.f.ip6.arpa ...
DNS configuration (for scoped queries)
resolver #1
search domain[0] : fritz.box
nameserver[0] : 192.168.178.1
if_index : 4 (en0)
flags : Scoped, Request A records
reach : Reachable,Directly Reachable Address
hostname
gets the FQDN from there on OS X, whereashost <hostname>
appears to query DNS (though I'm on 10.11…)hostname
to display the correct, full hostname including domain information. The part about the output of thehost
tool was only to show that my network setup and DNS seems to be working correctly otherwise...