1

I've RHEL 7.5 machine and when I hit hostname -d to get domain it returns nothing.

Also hostname -f, to return long host name returns name without domain.

Please help me to understand what changes I need to make hostname -d to return domain name.

1

1 Answer 1

1

From hostname man page:

It is not possible to set the FQDN or the DNS domain name with the dnsdomainname command (see THE FQDN below).

the Fqdn You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name.

Technically: The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.

Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.

You cannot change the FQDN with hostname or dnsdomainname.

The recommended method of setting the FQDN is to make the hostname be an alias for the fully qualified name using /etc/hosts, DNS, or NIS. For example, if the hostname was "ursula", one might have a line in /etc/hosts which reads 127.0.0.1 ursula.example.com ursula

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .