Answers
【hostname】命令: 显示主机名&修改主机名。
如:
[root@localhost ~]# hostname
localhost.localdomain
【host】命令: 把一个主机名解析到一个网际地址或把一个网际地址解析到一个主机名。
如:
[root@localhost ~]# host -a www.baidu.com
Trying "www.baidu.com"
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 659
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 4
;; QUESTION SECTION:
;www.baidu.com. IN ANY
;; ANSWER SECTION:
www.baidu.com. 3600 IN MX 10 kw-mx.gw.nic.fujitsu.com.
www.baidu.com. 3600 IN MX 10 yt-mx.gw.nic.fujitsu.com.
;; AUTHORITY SECTION:
. 2921 IN NS kw-root.gw.nic.fujitsu.com.
. 2921 IN NS yt-root.gw.nic.fujitsu.com.
;; ADDITIONAL SECTION:
kw-mx.gw.nic.fujitsu.com. 159 IN A 10.0.238.35
yt-mx.gw.nic.fujitsu.com. 73 IN A 10.134.59.35
yt-root.gw.nic.fujitsu.com. 287 IN A 10.134.61.144
kw-root.gw.nic.fujitsu.com. 74 IN A 10.0.238.36
Received 196 bytes from 10.167.129.6#53 in 101 ms
关于两个命令的详细使用说明可以自己查看linux命令的帮助文档。
【hostname】
[root@localhost ~]# hostname --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.
【host】
[root@localhost ~]# host --help
host: illegal option -- -
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
[-R number] [-m flag] hostname [server]
-a is equivalent to -v -t ANY
-c specifies query class for non-IN data
-C compares SOA records on authoritative nameservers
-d is equivalent to -v
-l lists all hosts in a domain, using AXFR
-i IP6.INT reverse lookups
-N changes the number of dots allowed before root lookup is done
-r disables recursive processing
-R specifies number of retries for UDP packets
-s a SERVFAIL response should stop query
-t specifies the query type
-T enables TCP/IP mode
-v enables verbose output
-w specifies to wait forever for a reply
-W specifies how long to wait for a reply
-4 use IPv4 query transport only
-6 use IPv6 query transport only
-m set memory debugging flag (trace|record|usage)
☆凤凰院凶真☆
answered 9 years, 9 months ago