TIPS/udhcpc

Last-modified: 2006-11-17 (金) 12:54:38

README.udhcpc

udhcp クライアント (udhcpc)


本udhcpクライアントはDHCPサーバからリースを行い、リース時と開放時にスクリプトを
呼びます(訳注:-sで指定したスクリプトが呼ばれます)。

コマンドラインオプション


udhcp用コマンドラインオプション:
-c, --clientid=CLIENTID         Client identifier
-H, --hostname=HOSTNAME         クライアントホスト名
-h,                  エイリアス -H と同意
-f, --foreground                リース取得後にフォークしません。
-b, --background                すぐにリースできない場合、バックグラウンドに
                                移行します。
-i, --interface=INTERFACE       対象となるイーサデバイス (初期値:eth0)
-n, --now                       すぐにリースできない場合、終了します。
-p, --pidfile=file              プロセスIDファイルの保存先パス
-q, --quit                      リース取得後に終了します。
-r, --request=IP                要求するIPアドレス (初期値:なし)
-s, --script=file               dhcpイベントで呼ばれるファイル (初期値:
                                /usr/share/udhcpc/default.script)
-v, --version                   バージョンを表示します。
もし要求したIPアドレスが取得できなかった場合、サーバが提示したIPアドレスに
設定されます(訳注:-rオプションの説明と思われます)。

渡される環境変数をみる

./udhcpc -i eth1 -f -q --script=./samples/dhcpc_info.sh

dhcpc_info.sh

READMEを改変した。

cat dhcpc_info.sh
#!/bin/sh
echo HOME=$HOME # The set $HOME env or "/"
echo PATH=$PATH # the set $PATH env or "/bin:/usr/bin:/sbin:/usr/sbin"
echo 1=$1 # What action the script should perform
echo interface=$interface # The interface this was obtained on
echo ip=$ip # The obtained IP
echo siaddr=$siaddr # The bootp next server option
echo sname=$sname # The bootp server name option
echo boot_file=$boot_file # The bootp boot file option
echo subnet=$subnet # The assigend subnet mask
echo timezone=$timezone # Offset in seconds from UTC
echo router=$router # A list of routers
echo timesvr=$timesvr # A list of time servers
echo namesvr=$namesvr # A list of IEN 116 name servers
echo dns=$dns # A list of DNS server
echo logsvr=$logsvr # A list of MIT#LCS UDP log servers
echo cookiesvr=$cookiesvr # A list of RFC 865 cookie servers
echo lprsvr=$lprsvr # A list of LPR servers
echo hostname=$hostname # The assigned hostname
echo bootsize=$bootsize # The length in 512 octect blocks of the bootfile
echo domain=$domain # The domain name of the network
echo swapsvr=$swapsvr # The IP address of the client's swap server
echo rootpath=$rootpath # The path name of the client's root disk
echo ipttl=$ipttl # The TTL to use for this network
echo mtu=$mtu # The MTU to use for this network
echo broadcast=$broadcast # The broadcast address for this network
echo ntpsrv=$ntpsrv # A list of NTP servers
echo wins=$wins # A list of WINS servers
echo lease=$lease # The lease time, in seconds
echo dhcptype=$dhcptype # DHCP message type (safely ignored)
echo serverid=$serverid # The IP of the server
echo message=$message # Reason for a DHCPNAK
echo tftp=$tftp # The TFTP server name
echo bootfile=$bootfile # The bootfile name