LinuxCommandLibrary

dnsdomainname

Display the system's DNS domain name

TLDR

Show the system's DNS domain name

$ dnsdomainname
copy

SYNOPSIS

dnsdomainname

PARAMETERS

None
    When invoked as dnsdomainname, the command typically takes no explicit parameters or options. Its behavior is fixed to display the DNS domain name, effectively acting as hostname -d.

DESCRIPTION

The dnsdomainname command is used to display the DNS (Domain Name System) domain name of the current system. It is typically a symbolic link to the hostname utility. When invoked as dnsdomainname, the hostname command behaves as if the -d option (--domain) was supplied, printing only the DNS domain portion of the system's fully qualified domain name (FQDN).

This command retrieves the DNS domain name, which is part of the system's network identity on the internet or a private network using DNS. This differs significantly from the domainname (or nisdomainname, ypdomainname) command, which pertains to the system's NIS (Network Information Service) or YP (Yellow Pages) domain name. The DNS domain name is crucial for network communication and service discovery via DNS, while the NIS domain name is relevant for NIS-based user and group management.

The DNS domain name is usually determined by the system's network configuration, often from /etc/resolv.conf or by performing a reverse DNS lookup on the system's IP address. If the system does not have a DNS domain name configured or discoverable, the command may output nothing or (none).

CAVEATS

  • Symbolic Link: dnsdomainname is almost always a symbolic link to the hostname command. This means its behavior is determined by how hostname interprets its invocation name.
  • Distinction from NIS/YP Domain: It is crucial not to confuse dnsdomainname with domainname (or nisdomainname, ypdomainname). dnsdomainname retrieves the DNS domain, which is part of the global internet naming system, while domainname deals with the NIS/YP domain, a legacy system for network-wide information distribution.
  • Lack of DNS Domain: If the system is not configured with a DNS domain name, or if it cannot be determined via reverse DNS lookup or /etc/resolv.conf, dnsdomainname may return an empty string or (none).
  • Configuration Dependency: The output relies on correct system network configuration, including /etc/hosts and /etc/resolv.conf, and potentially DNS server availability for reverse lookups.

HOW DNS DOMAIN IS DETERMINED

The DNS domain name displayed by dnsdomainname is typically obtained through one of the following methods:
1. From FQDN: If the system's full qualified domain name (FQDN) is set (e.g., myhost.example.com), the domain example.com is extracted. The FQDN can be set in /etc/hostname or via DHCP.
2. From /etc/resolv.conf: The domain or search directives in /etc/resolv.conf can provide the default DNS domain name.
3. Reverse DNS Lookup: The system may perform a reverse DNS lookup (PTR query) on its IP address to determine its associated domain name from DNS servers.

The exact method depends on the specific hostname implementation and system configuration.

HISTORY

The dnsdomainname command emerged as part of the hostname utility suite, primarily to provide a clear distinction between the system's DNS domain name and its NIS/YP domain name. In earlier Unix-like systems, the domainname command often served a dual purpose or was ambiguous regarding whether it referred to the NIS or DNS domain. As DNS became the predominant naming service, dnsdomainname was introduced to explicitly retrieve the DNS-specific domain information, making the system's network identity clearer and separating it from legacy NIS/YP configurations. Its integration as a symlink to hostname -d reflects the hostname utility's evolving capabilities to manage various aspects of a system's network identity.

SEE ALSO

hostname(1), domainname(1), nisdomainname(1), ypdomainname(1), gethostname(3), resolv.conf(5)

Copied to clipboard