|
サーバを作るには Static で IPアドレスを割り振ればよいのですが、単なるクライアントで使用するには別に DHCP でも良いわけです。で、最初に
Static に IPアドレスを割り振ったマシンを、あとから DHCP にする場合の方法です。
- DHCP にするインターフェースのファイルを修正します。
- 複数のインターフェースを持つ場合は DHCP にしたいインターフェースの、1つしかないときにはそのインターフェースの hostname.interface の中身を空にします。下記の例では、pcelx0 のインターフェースを DHCP にします。
# cd /etc
# touch hostname.pcelx0
- dhcp.interface のファイルを作成します。
- 中身は1行だけ記述します。start というのは、インターフェースの初期化の際に与えられるパラメータの1つで、通常コマンドでは、「ifconfig
pcexl0 dhcp start」と書くときの、start の部分になります。
# echo start > dhcp.pcelx0
- hosts の中身を書き換えます。というか、使っていたインターフェースに loghost がついていたら、それを移動させます。loghost
が最初から 127.0.0.1 にあれば、何もしないでOKです。
下記の下線部のように loghost を127.0.0.1 のところにすればOKです。関係無いのは残しておいて構いません。
#
# Internet host table
#
127.0.0.1 localhost loghost
-
- 次に、/etc/default/dhcpagent を修正します。
# cd /etc/default
# vi dhcpagent
下記の下線部のように REQUEST_HOSTNAME=yes と修正すればOKです。関係無いのは残しておいて構いません。
#ident "@(#)dhcpagent.dfl 1.7 01/02/12 SMI"
#
# Copyright (c) 2000-2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#
# This file contains tunable parameters for dhcpagent(1M).
#
# All parameters can be tuned for a specific interface by prepending
# the interface name to the parameter name. For example, to make
# RELEASE_ON_SIGTERM happen on all interfaces except hme0, specify:
#
# hme0.RELEASE_ON_SIGTERM=no
# RELEASE_ON_SIGTERM=yes
# By default, when the DHCP agent is sent a SIGTERM, all managed
# interfaces are dropped. By uncommenting the following
# parameter-value pair, all managed interfaces are released instead.
#
# RELEASE_ON_SIGTERM=yes
# When the DHCP agent gets an ACK from the server, it sends an ARP
# request to verify that a given IP address is not already in use. If
# an ARP reply is received, the DHCP agent declines the server's
# offer. However, if the DHCP agent is unable to send the ARP request
# packet for whatever reason, it assumes the address is available. To
# be more cautious, uncomment the following parameter-value pair.
#
# IGNORE_FAILED_ARP=no
# By default, the DHCP agent waits 3 seconds to collect OFFER
# responses to a DISCOVER. If it receives no OFFERs in this time, it
# then waits for another 3 seconds, and so forth. To change this
# behavior, set and uncomment the following parameter-value pair.
# Note: this does not control the retransmission strategy for
# DISCOVERs, which is formally specified in RFC 2131. This parameter
# is specified in seconds.
#
# OFFER_WAIT=
# By default, the DHCP agent waits 1000 milliseconds to collect ARP
# replies to an ARP request when verifying that an IP address is not
# in use. To change this behavior, set and uncomment the following
# parameter-value pair. This parameter is specified in milliseconds.
#
# ARP_WAIT=
# By default, the DHCP agent does not send out a client identifier
# (and hence, the chaddr field is used by the DHCP server as the
# client identifier.) To make the DHCP agent send a client
# identifier, set and uncomment the following parameter-value pair.
# Note that by default this is treated as an NVT ASCII string. To
# specify a binary value, prepend "0x" to a sequence of hexadecimal
# digits (for example, the value 0xAABBCC11 would set the client
# identifier to the 4-byte binary sequence 0xAA 0xBB 0xCC 0x11).
#
# CLIENT_ID=
# By default, the DHCP agent does not request the hostname currently
# associated with the interface performing DHCP. If this option is
# enabled, the agent will attempt to find a host name in /etc/hostname.<if>,
# which must contain a line of the form
#
# inet name
#
# where "name" is a single RFC 1101-compliant token. If found, the token
# will be used to request that host name from the DHCP server. To enable
# this behavior, uncomment the following line.
# REQUEST_HOSTNAME=yes
REQUEST_HOSTNAME=yes
# By default, a parameter request list requesting a subnet mask (1),
# router (3), hostname (12), and encapsulated vendor options (43), is
# sent to the DHCP server when the DHCP agent sends requests.
# However, if desired, this can be changed by altering the following
# parameter-value pair. Note that each option should be separated by
# a comma. For example, the value 20,30,40 requests that the DHCP
# server return the values for DHCP option codes 20, 30, and 40, as
# defined in RFC 2132.
#
PARAM_REQUEST_LIST=1,3,12,43
-
- dhcpagent が動いていたら停止します。(dhcp を使っていないなら動いていませんので不要です。)その後、dhcp 関連の情報が入っている
interface.dhc を削除しマシンを再起動すれば DHCP でアドレスと hostname を取得できるようになります。hostname を取得できない場合は
hostname が unknown になってしまいますが、とりあえずは IP アドレスは取得できるようです。
※どうやら Solaris8 07/01 以降でないと、hostname が自動でちゃんと取得できないようです。かつ、上記設定をしても DHCP
サーバ側の種類によっては、07/01 では hostname を取得できないようです。10/01 以降はちゃんと取得できます。
DHCP サーバから hostname を取得できない場合の対処方法
※ DHCP サーバから hostname を取得できている場合には、実施する必要はありません。
以下のようなコマンドを、dhcp の処理の後に加えるととりあえずは対処できます。
- /etc/nodename のファイルを作成します。中には 設定する hostname を1行記述します。
- /etc/init.d に以下のファイルを作成します。
下記の下線部のように loghost を127.0.0.1 のところにすればOKです。関係無いのは残しておいて構いません。
#!/sbin/sh
/usr/bin/uname -S `cat /etc/nodename`
※inetsvc の中でやっていることが判明したので、そのファイルを直しましょう。まず /etc/inet.d/inetsvc のファイルを修正します。
# cd /etc/init.d
# vi inetsvc
168行あたりに hostname="unknown" とあるので、そこに設定したい hostname を設定するように記述します。下記はその部分の抜粋で、下線の部分が修正したものです。
if [ "$_INIT_NET_STRATEGY" = "dhcp" ]; then
#
# if DHCP doesn't return a hostname, use "unknown" so
# client can resolve IP address into a local hostname.
#
hostname=`/sbin/dhcpinfo Hostname`
if [ -z "$hostname" ]; then
# hostname="unknown"
hostname=`cat /etc/nodename`
fi
- 作ったファイルの属性を変更しておきます。
- /etc/rc2.d からシンボリックリンクを張ります。
# cd /etc/rc2.d
# ln -s ../init.d/setuname S70setuname
|