Linux command
dnsdomainname 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Example
dnsdomainname
说明
dnsdomainname displays the DNS domain name portion of the system's fully qualified domain name (FQDN). It uses gethostname() to retrieve the hostname, then getaddrinfo() to resolve it to the canonical name via DNS lookup. The domain name is extracted as everything after the first dot in the FQDN. For example, if the FQDN is "server.example.com", dnsdomainname returns "example.com". This differs from tools like domainname which display the NIS/YP domain. The command requires proper DNS configuration and name resolution to work correctly. If the system hostname doesn't include a domain component or DNS resolution fails, it returns an empty result.
FAQ
What is the dnsdomainname command used for?
dnsdomainname displays the DNS domain name portion of the system's fully qualified domain name (FQDN). It uses gethostname() to retrieve the hostname, then getaddrinfo() to resolve it to the canonical name via DNS lookup. The domain name is extracted as everything after the first dot in the FQDN. For example, if the FQDN is "server.example.com", dnsdomainname returns "example.com". This differs from tools like domainname which display the NIS/YP domain. The command requires proper DNS configuration and name resolution to work correctly. If the system hostname doesn't include a domain component or DNS resolution fails, it returns an empty result.
How do I run a basic dnsdomainname example?
Run `dnsdomainname` in a terminal, then adjust file names, paths, flags, or remote targets for your system.