On Solaris, what is a terse way to get the fully qualified domain name (fqdn) for the current host

From here:

The hostname command should return an FQDN...
...
The solution is to edit /etc/nodename and put the FQDN in there and reboot.

    echo foo.your.domain.com > /etc/nodename

You might also be able to use:

getent hosts `hostname` | cut -f 3

or similar.


Your method depends upon the /etc/hosts file being formatted in a particular way, on a S10 system I have to hand it returns loghost which is incorrect.

If set up you can ask the DNS system with

dig -x your.ip.add.ress +short

or if you are using NIS then

echo `hostname`.`domainname`

or you could setup /etc/nodename as Dennis suggests.