[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)
【hostname】指令: 顯示主機名稱&修改主機名稱。
如:
【host】指令: 把一個主機名稱解析到一個網際位址或把一個網路位址解析到一個主機名稱。
如:
關於兩個指令的詳細使用說明可以自己檢視linux指令的說明文件。
【hostname】
【host】
hostname就是主機名,還可以透過cat /proc/sys/kernel/hostname查看
改主機名稱一般是改/etc/sysconfig/network這個文件,需要重新啟動網路;或用hostname指令改,但重新啟動後會恢復
/etc/hosts功能相當於DNS,記錄IP到主機名稱/網域的映射
hostname是主機名稱,用來識別你的機器.如果你同時連接到多台主機進行操作,這時,主機名稱就能用來區分你到底
目前使用的是哪一台機器了!如果主機名稱都一樣......