Go to main content

man pages section 1M: System Administration Commands

Exit Print View

Updated: July 2017



domainname - set or display name of the current domain


domainname [name-of-domain]


Without an argument, domainname displays the name of the current domain name used in RPC exchanges, usually referred to as the NIS domain name. This name typically encompasses a group of hosts or passwd entries under the same administration. The domainname command is used by various components of Solaris to resolve names for entries such as are found in passwd, hosts and aliases. By default, naming services such as NIS use domainname to resolve names.

With the “Name Service Management” rbac(5) profile, you can permanently set the name of the domain with the following command:

% domainname nisdomain.example.com

If not yet enabled, the nis/domain service is enabled.

The super-user can temporary set the domain name using:

# domainname -t nisdomain.example.com

The domain name for various naming services can also be set by other means. DNS ignores the domain name set by domainname and LDAP uses it as a last resort.

The sendmail(1M) daemon, as shipped with Solaris, and the sendmail implementation provided by sendmail.org (formerly referred to as “Berkeley 8.x sendmail”) both attempt to determine a local host's fully qualified host name at startup and both pursue follow-up actions if the initial search fails. It is in these follow-up actions that the two implementations differ.

Both implementations use a standard Solaris or Unix system call to determine its fully qualified host name at startup, following the name service priorities specified in nsswitch.conf(4). To this point, the Solaris and sendmail.org versions behave identically.

If the request for a fully qualified host name fails, the sendmail.org sendmail sleeps for 60 seconds, tries again, and, upon continuing failure, resorts to a short name. The Solaris version of sendmail makes the same initial request, but then, following initial failure, calls domainname. If successful, the sleep is avoided.

On a Solaris machine, if you run the sendmail.org version of sendmail, you get the startup behavior (omitting the domainname call) described above. If you run the Solaris sendmail, the domainname call is made if needed.

If the Solaris sendmail cannot determine the fully qualified host name, use check-hostname(1M) as a troubleshooting aid. This script can offer guidance as to appropriate corrective action.


  • /etc/defaultdomain

  • /etc/nsswitch.conf


See attributes(5) for descriptions of the following attributes:


See Also

svcs(1), check-hostname(1M), hostconfig(1M), named(1M), sendmail(1M), svcadm(1M), svccfg(1M), ypinit(1M), aliases(4), defaultdomain(4), hosts(4), nsswitch.conf(4), passwd(4), attributes(5), rbac(5), smf(5)


The domainname service is managed by the service management facility, smf(5), under the service identifier:


Administrative actions on this service, such as enabling, disabling, or requesting restart, can be performed using svcadm(1M). The service's status can be queried using the svcs(1) command.