LinuxCommandLibrary

domainname

Display or set network domain name

SYNOPSIS

domainname [<name>]
domainname [--help]
domainname [--version]

PARAMETERS

<name>
    (Optional) The desired NIS/YP domain name to set. Requires superuser privileges. If omitted, the current NIS domain name is displayed.

--help
    Displays a help message and exits.

--version
    Displays version information and exits.

DESCRIPTION

domainname is a command-line utility used to query or set the Network Information Service (NIS), formerly known as Yellow Pages (YP), domain name of the current system.

When invoked without any arguments, it displays the currently configured NIS domain name. If an argument (the desired domain name) is provided, domainname attempts to set the system's NIS domain name. It's crucial to understand that this command manages the NIS domain name, which is distinct from the DNS domain name used for internet name resolution. Setting the NIS domain name typically requires superuser privileges and is often temporary for the current session, meaning it won't persist across reboots unless configured via system-specific startup scripts or network configuration files. NIS is an older client/server directory service primarily used for distributing configuration data like user accounts and hostnames across a network.

CAVEATS

Setting the NIS domain name using domainname <name> usually requires root privileges.
The change made by domainname <name> is typically not persistent across system reboots. For permanent changes, refer to your operating system's network configuration documentation (e.g., /etc/sysconfig/network on Red Hat-based systems, /etc/defaultdomain or similar on others).
This command manages the NIS/YP domain name, which is conceptually different from the DNS domain name used for internet name resolution. Do not confuse the two.

NIS VS. DNS DOMAIN

It is a common misconception that domainname refers to the DNS domain name. In reality, domainname manages the NIS (Network Information Service) or YP (Yellow Pages) domain name. The DNS domain name, used for resolving hostnames to IP addresses on the internet and local networks, is typically displayed by the dnsdomainname(1) command or derived from your DNS resolver configuration (e.g., /etc/resolv.conf).

MAKING CHANGES PERSISTENT

While domainname <name> sets the NIS domain name for the current session, this change is not permanent. To ensure the NIS domain name is set automatically upon system boot, you must configure it in system-specific network configuration files. Common locations or methods include setting NISDOMAIN in /etc/sysconfig/network (Red Hat/CentOS), defining it in /etc/defaultdomain, or through network manager configurations, depending on your Linux distribution.

HISTORY

The domainname command has its origins in Sun Microsystems' Network Information Service (NIS), originally called Yellow Pages (YP). Due to trademark issues, "Yellow Pages" was renamed to NIS. The command has been a staple in Unix-like operating systems that supported NIS for distributing system configuration data. It's typically part of the net-tools or nis-tools packages. While once prevalent, the use of NIS has declined significantly in favor of more modern and secure distributed directory services like LDAP and Kerberos, and DNS for primary name resolution.

SEE ALSO

hostname(1), nisdomainname(1), dnsdomainname(1), ypbind(8)

Copied to clipboard