linux操作系统下 dnsdomainname 命令介绍和使用案例
dnsdomainname 命令介绍
dnsdomainname
是一个用于显示系统的 DNS 域名的命令。在 Linux 操作系统中,它通常与 hostname
命令一起使用,以获取机器的网络标识信息。
功能
- 显示 DNS 域名:该命令返回当前主机的 DNS 域名部分,通常是完全合格域名(FQDN)的一部分。
- 与 NIS 相关:在某些系统中,
dnsdomainname
也可以用于设置或显示 NIS(Network Information Service)域名。
命令介绍
root@doris23:/data# which dnsdomainname
/usr/bin/dnsdomainname
root@doris23:/data# dnsdomainname --help
Usage: hostname [-b] {hostname|-F file} set host name (from file)
hostname [-a|-A|-d|-f|-i|-I|-s|-y] display formatted name
hostname display host name
{yp,nis,}domainname {nisdomain|-F file} set NIS domain name (from file)
{yp,nis,}domainname display NIS domain name
dnsdomainname display dns domain name
hostname -V|--version|-h|--help print info and exit
Program name:
{yp,nis,}domainname=hostname -y
dnsdomainname=hostname -d
Program options:
-a, --alias alias names
-A, --all-fqdns all long host names (FQDNs)
-b, --boot set default hostname if none available
-d, --domain DNS domain name
-f, --fqdn, --long long host name (FQDN)
-F, --file read host name or NIS domain name from given file
-i, --ip-address addresses for the host name
-I, --all-ip-addresses all addresses for the host
-s, --short short host name
-y, --yp, --nis NIS/YP domain name
Description:
This command can get or set the host name or the NIS domain name. You can
also get the DNS domain or the FQDN (fully qualified domain name).
Unless you are using bind or NIS for host lookups you can change the
FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
part of the FQDN) in the /etc/hosts file.
命令案例
root@doris23:/data# dnsdomainname
root@doris23:/data# hostname -f
doris23
root@doris23:/data# dnsdomainname -a
root@doris23:/data# dnsdomainname -A
jira.umi-meta.com doris23 doris23
root@doris23:/data# dnsdomainname -y
dnsdomainname: Local domain name not set
root@doris23:/data# dnsdomainname -i
192.168.10.23 172.17.0.1 172.18.0.1 fe80::20c:29ff:fed4:e2de
root@doris23:/data#