dhclient(8) dhclient(8) 名称 dhclient - 動的ホスト設定プロトコルのクライアント 書式 dhclient [ -p port ] [ -D ] [ -d ] [ -q ] [ -1 ] [ -r ] [ -lf lease- file ] [ -pf pid-file ] [ -cf config-file ] [ -sf script-file ] [ -s server ] [ -g relay ] [ -n ] [ -nw ] [ -w ] [ if0 [ ...ifN ] ] 解説 Internet Software Consortium の DHCP クライアントである dhclient は動的 ホスト設定プロトコル (DHCP: Dynamic Host Configuration Protocol) または BOOTP プロトコルを用いて、あるいはこれらのプロトコルが失敗した場合には アドレスを静的に割り当てて、 1 つ以上のネットワークインタフェースを設定 する方法を提供します。 操作 DHCP プロトコルでは、1 つ以上のサブネットに割り当てることのできる IP ア ドレスのリストを管理する中央サーバに、ホストがアクセスできます 。 DHCP ク ライアントはこのリストからアドレスを要求して、それをネットワーク通信 の一時的な土台に用いることができます。また DHCP プロトコルは、デフォ ル ト ルータの場所やネームサーバの場所など、クライアントが接続しているネッ トワークに関する重要な情報をクライアントに詳細に知らせる機構も提供し ま す。 起動時に dhclient は dhclient.conf から設定指示を読み取ります。それから 現在のシステムに組み込まれているすべてのネットワークインタフェースの リ ス トを取得します。各インタフェースに対し dhclient は DHCP プロトコルを 用いて設定を試みます。 システムリブートやサーバ再起動の際にリースを失わないように 、 dhclient は 割り当てられたリースのリストを dhclient.leases(5) ファイルに保存しま す。起動時、dhclient.conf ファイルを読 み 取 っ た 後 、 dhclient は dhclient.leases ファイルを読み込んで、割り当てられたリースに関するメモ リを更新します。 新しいリースを取得すると、dhclient.leases ファイルの末尾に付け加えら れ ま す。ファイルが極端に大きくなるのを防ぐために、 dhclient は時おりコア 内部のリースデータベースから新規に dhclient.leases ファイルを作成します 。古い dhclient.leases ファイルは、 dhclient が次にデータベースを作り替 えるまで、 dhclient.leases~ という名前で保存されます。 dhclient が最初に起動されたとき (一般的にはシステムブート初期過程の 間) に DHCP サ ー バが利用できなければ、古いリースは残されます。その場合 、dhclient.leases ファイルからまだ期限の切れていない古いリースを検査 し 、 有効であると判断されれば、それらの期限が切れるかまたは DHCP サーバが 利用できるようになるまで、そのリースを使います。 DHCP サーバが存在しないネットワークに時おりアクセスする必要があるような 移 動ホストは、そのネットワーク上の固定アドレスのリースをあらかじめ読み 込んでおくことができます。 DHCP サーバへのアクセスがどれも成功しなか っ た 場合、 dhclient はその静的なリースが有効であるか検証し、有効であれば 次に再起動されるまでそのリースを使います。 また移動ホストは、DHCP は利用できないが BOOTP なら利用できるようなネ ッ ト ワークへ移動することもあるでしょう。そのような場合は、古いリースを順 次試すよりも、そのネットワークの管理者と相談して BOOTP データベースにエ ン トリを作成してもらい、そのネットワーク上で素早くブートできるようにす るとよいでしょう。 コマンドライン dhclient が設定しようとするネットワークインタフェースの名前をコマンドラ イ ンで指定できます。コマンドラインでインタフェース名が指定されなければ 、 dhclient はすべてのネットワークインタフェースを識別し、可能なら非 ブ ロ ードキャストインタフェースは除いて、それぞれのインタフェースを設定し ようとします。 dhclient.conf(5) ファイル中の名前でインタフェースを指定することも可能で す 。この方法でインタフェースを指定した場合、クライアントは、設定ファイ ル中で指定したインタフェースもしくはコマンド行で指定したインタフェー ス のどちらかだけを設定するでしょう。 -D フラグを指定すると、 dhclient が dhclient-script と組み合わせて使用 するために作成したスクリプトを、 /tmp に保存させます。 DHCP クライアントが標準ポート (ポート番号 68) 以外のポートで待機およ び 送 信 す る 必 要がある場合には -p フラグが使えます。このフラグに続けて 、dhclient が使う udp ポート番号を指定します。これは主としてデバッグ 目 的 では有用です。クライアントが待機および送信するために使用するポートに デフォルトとは違うポートを指定する場合、クライアントはもう 1 つ別の送信 先 ポートも使用します。その送信先ポートは、指定した送信先ポートよりも大 きな番号を持ったものです。 DHCP クライアントは、通常 IP アドレスを獲得していない間任意のプロトコル メッセージをリミテッドブロードキャストアドレスである 255.255.255.255 へ と送信します。デバッグ目的で、サーバがこれらのメッセージをどこか別の ア ド レ スへ送信した方が便利なことがあります。 -s フラグの後に送信先の IP アドレスもしくはドメイン名をつけて指定できます。テスト目的で、DHCP クラ イ アントが送信する全てのパケットの giaddr フィールドを -g フラグに送信 先の IP アドレスを続けた形を使用することで設定することができます。こ れ は テスト目的の時のみ有用なものであり、堅実さや使いやすさを求める状況で 動作することを想定してはいけません。 DHCP クライアントは、通常インタフェースを設定するまではフォアグラウンド で動作し、その後バックグラウンドで動作するようになります。dhclient を常 にフォアグラウンドのプロセスとして動作させるためには、 -d フラグを指 定 する必要があります。これは、DHCP クライアントがデバッガのもとで動作して いる場合や、System V システムの inittab の外側で動作している場合には 有 効なものです。 こ のクライアントは、通常は起動メッセージを表示し、アドレスを獲得するま で標準エラー出力にプロトコルシーケンスを書き出します。アドレスを獲得 し た 後は syslog (3) ファシリティを使用してメッセージのログを取るだけにな ります。 -q フラグを使用すると、エラー以外のメッセージを標準エラー出 力 に書き出さないようになります。 クライアントは、DHCP プロトコルで義務づけられていないため、通常は現在取 得しているリースを開放することはありません。ただ、ケーブル ISP のなかに は、クライアントが割り当てられたIP アドレスを開放したい場合には、サーバ に通知するように義務づけているところもあります。 -r フラグを用いると 、 明 示的に現在のリースを開放し、いったんリースを開放するとクライアントは 終了します。 -1 フラグを指定すると、 dhclient はひとつのリースに対し 1 度だけしか 取 得を試みません。もし取得に失敗すれば dhclient は終了コード 2 で終了しま す。 DHCP クライアントは、通常は設定情報を ETCDIR/dhclient.conf から、リース デ ー タベースを DBDIR/dhclient.leases から取得し、自分のプロセス ID を RUNDIR/dhclient.pid という名前のファイルに保存し、そしてネットワーク イ ン タフェースを CLIENTBINDIR/dhclient-script を使用して設定します。これ らのファイルに別の名前を指定したり、別の場所を指定したりするには、そ れ ぞ れ -cf, -lf, -pf および -sf フラグを、後ろにファイル名を続ける形で使 用してください。この方法は、例えば DHCP クライアントが起動した と き に DBDIR もしくは RUNDIR がまだマウントされていない場合には特に有用なもの になり得ます。 DHCP クライアントは、設定すべきネットワークインタフェースを同定できない 場 合、通常は終了します。ラップトップコンピュータやホットスワップ可能な I/O バスを持ったコンピュータでは、ブロードキャストインタフェースがシ ス テ ム起動後に追加されることがあり得ます。 -w フラグを用いると、そのよう なインタフェースが 1 つも見つからないときにもクライアントが終了しないよ うにできます。後で omshell (8) プログラムを使用して、ネットワークインタ フェースが追加されたり削除されたりしたことをクライアントに通知するこ と が でき、これによってクライアントがこのインタフェース上の IP アドレスを 設定するよう試みることができます。 -n フラグを用いることで、どのインタフェースも設定しようとしないよ う に DHCP クライアントを指示することができます。このフラグは、きっと -w フラ グと共に使用すると有用でしょう。 IP アドレスを獲得するまで待つのではなく、即座にデーモンとなるようにクラ イアントを指示することもできます。 -nw フラグを与えると可能です。 設定 dhclient.conf(5) ファイルの書式は別に解説されています。 OMAPI こ の DHCP クライアントは、動作中にその動作を停止させることなく自分自身 を制御できるようにするための機能を提供しています。この機能は、リモー ト オ ブジェクト操作 API である OMAPI を用いて提供されています。OMAPI クラ イアントは、TCP/IP を使用してこの DHCP クライアントに接続します。そして 、 DHCP クライアントの現在の状態を検査でき、その状態を変更することがで きます。 ユーザプログラムでは、基礎にある OMAPI プロトコルを直接実装するのではな く 、dhcpctl API もしくは OMAPI そのものを使用すべきです。 dhcpctl は 、OMAPI が自動で行ってはくれない雑事のいくつかを扱うラッパです。dhcpctl および OMAPI については dhcpctl(3) および omapi(3) に記述されています。 クライアントを用いてやりたいことのほとんどは、特別なプログラムを書か な くとも omshell(1) コマンドを使用して直接実現できるものです。 制御オブジェクト 制御オブジェクトを使用すると、DHCP クライアントを終了させ、保持している リースをすべて開放し、クライアントが追加した DNS レコードをすべて消去す る ことができるようになります。また、クライアントを一時停止させ、クライ アントが使用しているインタフェースの設定を除くことができるようにもな り ます。その後で、DHCP クライアントを再起動させることができ、インタフェー スを再設定することができます。通常、ハイバネーションに入る前やラップ ト ッ プコンピュータではスリープする前に DHCP クライアントを一時停止させる でしょう。そして、電源が戻ってきた後で DHCP クライアントを回復させる で し ょう。こうすることで、コンピュータがハイバネーションやスリープ中には PC カードを停止させておき、コンピュータがハイバネーションやスリープから 復帰したら以前の状態に再度初期化することができるようになるのです。 制御オブジェクトには属性が 1 つあります。それは状態属性です。クライアン トを終了させるには、クライアントの状態属性を 2 に設定します。クライアン トは自動的に DHCPRELEASE を行うでしょう。クライアントを一時停止させるに は、クライアントの状態属性を 3 に設定します。クライアントを復帰させるに は、クライアントの状態属性を 4 に設定します。 関連ファイル CLIENTBINDIR/dhclient-script, ETCDIR/dhclient.conf, DBDIR/dhclient.leases, RUNDIR/dhclient.pid, DBDIR/dhclient.leases~ 関連項目 dhclient.conf(5), dhclient.leases(5), dhclient-script(8) 作者 dhclient(8) は Ted Lemon が Vixie Enterprises と協力して Internet Soft- ware Consortium のために書きました。 Internet Software Consortium につ いてより詳しくは、 http://www.isc.org をご覧くださ い 。 Vixie Enter- prises についてより詳しくは、 http://www.vix.com をご覧ください。 本 クライアントは、Elliot Poger が Stanford 大学の MosquitoNet プロジェ クトに参加している間に、 Linux での利用に際し大幅に修正、改良を行いまし た。 現 在のバージョンは、Elliot による Linux での改良に負うところが大きいで すが、 Internet Software Consortium の DHCP サーバが使うものと同じネ ッ ト ワーキングフレームワークを用いるように、Ted Lemon が大幅な再編成や部 分的な書き換えを行いました。システム特有の設定コードの大部分はシェル ス ク リプトに移されたので、より多くのオペレーティングシステムのサポートが 加えられるにつれ、システム特有の設定コードをそのオペレーティングシス テ ム に移植したり管理したりする必要はなくなるでしょう。代わりに、シェルス クリプトが環境に合ったツールを呼び出してその目的を果たしてくれます。 dhclient(8)
dhclient(8) dhclient(8)
NAME
dhclient - Dynamic Host Configuration Protocol Client
SYNOPSIS
dhclient [ -4 | -6 ] [ -S ] [ -N [ -N... ] ] [ -T [ -T... ] ] [ -P [
-P... ] ] [ -p port ] [ -d ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r | -x
] [ -lf lease-file ] [ -pf pid-file ] [ -cf config-file ] [ -sf script-
file ] [ -s server ] [ -g relay ] [ -n ] [ -nc ] [ -nw ] [ -w ] [ -B ]
[ -I dhcp-client-identifier ] [ -H host-name ] [ -F fqdn.fqdn ] [ -V
vendor-class-identifier ] [ -R request-option-list ] [ -timeout timeout
] [ -v ] [ --version ] [ if0 [ ...ifN ] ]
DESCRIPTION
The Internet Systems Consortium DHCP Client, dhclient, provides a means
for configuring one or more network interfaces using the Dynamic Host
Configuration Protocol, BOOTP protocol, or if these protocols fail, by
statically assigning an address.
OPERATION
The DHCP protocol allows a host to contact a central server which main-
tains a list of IP addresses which may be assigned on one or more sub-
nets. A DHCP client may request an address from this pool, and then
use it on a temporary basis for communication on network. The DHCP
protocol also provides a mechanism whereby a client can learn important
details about the network to which it is attached, such as the location
of a default router, the location of a name server, and so on.
On startup, dhclient reads the dhclient.conf for configuration instruc-
tions. It then gets a list of all the network interfaces that are
configured in the current system. For each interface, it attempts to
configure the interface using the DHCP protocol.
In order to keep track of leases across system reboots and server
restarts, dhclient keeps a list of leases it has been assigned in the
dhclient.leases(5) file. On startup, after reading the dhclient.conf
file, dhclient reads the dhclient.leases file to refresh its memory
about what leases it has been assigned.
When a new lease is acquired, it is appended to the end of the
dhclient.leases file. In order to prevent the file from becoming
arbitrarily large, from time to time dhclient creates a new
dhclient.leases file from its in-core lease database. The old version
of the dhclient.leases file is retained under the name dhclient.leases~
until the next time dhclient rewrites the database.
Old leases are kept around in case the DHCP server is unavailable when
dhclient is first invoked (generally during the initial system boot
process). In that event, old leases from the dhclient.leases file
which have not yet expired are tested, and if they are determined to be
valid, they are used until either they expire or the DHCP server
becomes available.
A mobile host which may sometimes need to access a network on which no
DHCP server exists may be preloaded with a lease for a fixed address on
that network. When all attempts to contact a DHCP server have failed,
dhclient will try to validate the static lease, and if it succeeds,
will use that lease until it is restarted.
A mobile host may also travel to some networks on which DHCP is not
available but BOOTP is. In that case, it may be advantageous to
arrange with the network administrator for an entry on the BOOTP
database, so that the host can boot quickly on that network rather than
cycling through the list of old leases.
COMMAND LINE
The names of the network interfaces that dhclient should attempt to
configure may be specified on the command line. If no interface names
are specified on the command line dhclient will normally identify all
network interfaces, eliminating non-broadcast interfaces if possible,
and attempt to configure each interface.
It is also possible to specify interfaces by name in the
dhclient.conf(5) file. If interfaces are specified in this way, then
the client will only configure interfaces that are either specified in
the configuration file or on the command line, and will ignore all
other interfaces.
OPTIONS
-4 Use the DHCPv4 protocol to obtain an IPv4 address and configura-
tion parameters (default).
-6 Use the DHCPv6 protocol to obtain whatever IPv6 addresses are
available along with configuration parameters. The functional-
ity of DHCPv6 mode may be modified with the -S , -T , and -N
options.
-S Perform an information-only request over DHCPv6 to get stateless
configuration parameters. It is not recommended to combine this
option with the -N , -P , or -T options or to share lease files
between different modes of operation. Only valid with the -6
option.
-N Perform a normal (IA_NA) address query over DHCPv6. It is not
recommended to combine this option with the -P , -S , or -T
options or to share lease files between different modes of oper-
ation. Only valid with the -6 option.
-T Perform a temporary (IA_TA) address query over DHCPv6 (disables
normal address query). It is not recommended to combine this
option with the -N , -P , or -S options or to share lease files
between different modes of operation. Only valid with the -6
option.
-P Enable IPv6 prefix delegation (disables normal address query).
It is not not recommended to combine this option with the -N ,
-S , or -T options or to share lease files between different
modes of operation. Only valid with the -6 option.
-p
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa