HOSTNAME(1) Linux Programmer’s Manual HOSTNAME(1)
名前
hostname - システムのホスト名を表示・設定する
domainname - システムの NIS/YP ドメイン名を表示・設定する
dnsdomainname - システムの DNS ドメイン名を表示する
nisdomainname - システムの NIS/YP ドメイン名を表示・設定する
ypdomainname - システムの NIS/YP ドメイン名を表示・設定する
nodename - システムの DECnet ノード名を表示・設定する
書式
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-i] [--ip-
address] [--long] [-s] [--short] [-y] [--yp] [--nis] [-n] [--node]
hostname [-v] [-F filename] [--file filename] [hostname]
domainname [-v] [-F filename] [--file filename] [name]
nodename [-v] [-F filename] [--file filename] [name]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
nisdomainname [-v]
ypdomainname [-v]
説明
hostname はシステムの現在のホスト名・ドメイン名・ノード名を設定/表示 す
る ために用いられるプログラムである。これらの名前は、多くのネットワーク
プログラムでマシンを特定するために用いられる。ドメイン名は NIS/YP で も
用いられる。
名前の取得
引き数なしで実行された場合は、プログラムは現在の名前を表示する:
hostname は gethostname(2) 関数から返されたシステムの名前を表示する。
domainname, nisdomainname, ypdomainname は getdomainname(2) 関数から返
されたシステムの名前を表示する。これはシステムの NIS/YP ドメイン名で も
ある。
nodename は getnodename(2) 関数から返された、システムの DECnet ノード名
を表示する。
dnsdomainname は FQDN (Fully Qualified Domain Name) のドメイン部を表 示
する。システムの完全な FQDN は hostname --fqdn によって表示させることが
できる。
名前の設定
引き数が一つ与えられた場合や --file オプションが指定された場合は、コ マ
ンドはホスト名・ NIS/YP ドメイン名・ノード名を設定する。
スーパーユーザーだけがこれらの名前を変更できることに注意すること。
dnsdomainname コマンドによって FQDN や DNS ドメイン名を変更することはで
きない (以下の FQDN を見よ)。
一般的にホスト名は、システムの起動時に一度だけ、 /etc/rc.d/rc.inet1 ま
た は /etc/init.d/boot で設定される (通常この際にはホスト名が書かれてい
るファイル、例えば /etc/hostname が読み込まれる)。
FQDN
FQDN ( hostname --fqdn で返される値) や DNS ドメイン名 ( dnsdomainname
で 返 される値) をこのコマンドで変更することはできない。システムの FQDN
は resolver(3) がホスト名として返す名前である。
技術的背景: FQDN は gethostname(2) が返した値に対して gethostbyname(2)
が返す名前である。 DNS ドメイン名は最初のドット (.) 以降の部分である。
し たがってこれを変更する方法は設定 (通常は /etc/host.conf ) に依存する
。一般的には (hosts ファイルが DNS や NIS より先に解釈されるなら) 変 更
は /etc/hosts でできる。
オプション
-a, --alias
ホストの別名 (alias) があれば表示する。
-d, --domain
DNS ド メ イ ンの名前を表示する。 DNS ドメイン名を取得する際に
domainname を用いてはならない。なぜなら domainname が表示する の
は NIS のドメイン名であって DNS のものではないからである。この用
途には dnsdomainname を用いること。
-F, --file filename
ホスト名を指定したファイルから読む。コメント (‘#’ で始まる行) は
無視する。
-f, --fqdn, --long
FQDN (Fully Qualiifed Domain Name) を表示する。 FQDN は短い形式
のホスト名と DNS ドメイン名からなる。 bind または NIS をホスト名
の 検索に用いていない場合は FQDN と DNS ドメイン名 (FQDN の一部)
を /etc/hosts ファイルで変更することもできる。
-h, --help
使用方法に関するメッセージを表示して終了する。
-i, --ip-address
ホストの IP アドレス (複数の場合あり) を表示する。
-n, --node
DECnet ノード名を表示する。もしパラメータが与えられた場合(または
--filename が指定された場合) には、 root であれば 新しいノード名
を設定できる。
-s, --short
短い形式のホスト名を表示する。これは最初のドット (.) までの名 前
である。
-V, --version
バージョン情報を標準出力に表示して実行成功を返す。
-v, --verbose
饒舌モード。起こっていることを逐一表示する。
-y, --yp, --nis
NIS ド メ イン名を表示する。パラメータが与えられた場合 (または
--filename が指定された場合) には、 root であれば NIS ドメインを
設定できる。
ファイル
/etc/hosts
著者
Peter Tobias,
HOSTNAME(1) Linux Programmer’s Manual HOSTNAME(1)
NAME
hostname - show or set the system’s host name
domainname - show or set the system’s NIS/YP domain name
dnsdomainname - show the system’s DNS domain name
nisdomainname - show or set system’s NIS/YP domain name
ypdomainname - show or set the system’s NIS/YP domain name
SYNOPSIS
hostname [-v] [-a] [--alias] [-d] [--domain] [-f] [--fqdn] [-A] [--all-
fqdns] [-i] [--ip-address] [-I] [--all-ip-addresses] [--long] [-s]
[--short] [-y] [--yp] [--nis]
hostname [-v] [-F filename] [--file filename] [hostname]
domainname [-v] [-F filename] [--file filename] [name]
nodename [-v] [-F filename] [--file filename] [name]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
nisdomainname [-v]
ypdomainname [-v]
DESCRIPTION
Hostname is the program that is used to either set or display the cur-
rent host, domain or node name of the system. These names are used by
many of the networking programs to identify the machine. The domain
name is also used by NIS/YP.
GET NAME
When called without any arguments, the program displays the current
names:
hostname will print the name of the system as returned by the gethost-
name(2) function.
domainname, nisdomainname, ypdomainname will print the name of the sys-
tem as returned by the getdomainname(2) function. This is also known as
the YP/NIS domain name of the system.
dnsdomainname will print the domain part of the FQDN (Fully Qualified
Domain Name). The complete FQDN of the system is returned with hostname
--fqdn.
The function gethostname(2) is used to get the hostname. When the
hostname -a, -d, -f or -i is called will gethostbyname(3) be called.
The difference in gethostname(2) and gethostbyname(3) is that gethost-
byname(3) is network aware, so it consults /etc/nsswitch.conf and
/etc/host.conf to decide whether to read information in
/etc/sysconfig/network or /etc/hosts
To add another dimension to this, the hostname is also set when the
network interface is brought up.
SET NAME
When called with one argument or with the --file option, the commands
set the host name, the NIS/YP domain name or the node name.
Note, that only the super-user can change the names.
It is not possible to set the FQDN or the DNS domain name with the dns-
domainname command (see THE FQDN below).
The host name is usually set once at system startup in
/etc/rc.d/rc.inet1 or /etc/init.d/boot (normally by reading the con-
tents of a file which contains the host name, e.g. /etc/hostname).
THE FQDN
You can’t change the FQDN (as returned by hostname --fqdn) or the DNS
domain name (as returned by dnsdomainname) with this command. The FQDN
of the system is the name that the resolver(3) returns for the host
name.
Technically: The FQDN is the name gethostbyname(2) returns for the host
name returned by gethostname(2). The DNS domain name is the part after
the first dot.
Therefore it depends on the configuration (usually in /etc/host.conf)
how you can change it. Usually (if the hosts file is parsed before DNS
or NIS) you can change it in /etc/hosts.
If a machine has multiple network interfaces/addresses or is used in a
mobile environment, then it may either have multiple FQDNs/domain names
or none at all. Therefore avoid using hostname --fqdn, hostname
--domain and dnsdomainname. hostname --ip-address is subject to the
same limitations so it should be avoided as well.
OPTIONS
-a, --alias
Display the alias name of the host (if used).
-d, --domain
Display the name of the DNS domain. Don’t use the command
domainname to get the DNS domain name because it will show the
NIS domain name and not the DNS domain name. Use dnsdomainname
instead.
-F, --file filename
Read the host name from the specified file. Comments (lines
starting with a ‘#’) are ignored.
-f, --fqdn, --long
Display the FQDN (Fully Qualified Domain Name). A FQDN consists
of a short host name and the DNS domain name. Unless you are
using bind or NIS for host lookups you can change the FQDN and
the DNS domain name (which is part of the FQDN) in the
/etc/hosts file. See the warnings in section THE FQDN above, and
avoid using this option; use hostname --all-fqdns instead.
-A, --all-fqdns
Displays all FQDNs of the machine. This option enumerates all
configured network addresses on all configured network inter-
faces, and translates them to DNS domain names. Addresses that
cannot be translated (i.e. because they do not have an appropri-
ate reverse DNS entry) are skipped. Note that different
addresses may resolve to the same name, therefore the output may
contain duplicate entries. Do not make any assumptions about the
order of the output.
-h, --help
Print a usage message and exit.
-i, --ip-address
Display the IP address(es) of the host. Note that this works
only if the host name can be resolved. Avoid using this option;
use hostname --all-ip-addresses instead.
-I, --all-ip-addresses
Display all network addresses of the host. This option enumer-
ates all configured addresses on all network interfaces. The
loopback interface and IPv6 link-local addresses are omitted.
Contrary to option -i, this option does not depend on name reso-
lution. Do not make any assumptions about the order of the out-
put.
-s, --short
Display the short host name. This is the host name cut at the
first dot.
-V, --version
Print version information on standard output and exit success-
fully.
-v, --verbose
Be verbose and tell what’s going on.
-y, --yp, --nis
Display the NIS domain name. If a parameter is given (or --file
name ) then root can also set a new NIS domain.
FILES
/etc/hosts /etc/sysconfig/network
NOTE
Note that hostname doesn’t change anything permanently. After reboot
original names from /etc/hosts are used again.
AUTHOR
Peter Tobias,
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa