dhcp サーバ
必要に応じて dhcp サーバをセットアップします。
dhcp サーバのインストール
apt-get で dhcp パッケージをインストールします。
hackkit:~# apt-get install dhcp
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
dhcp
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 114kB of archives.
After unpacking 340kB of additional disk space will be used.
Get:1 http://ftp2.jp.debian.org proposed-updates/main dhcp 2.0pl5-19.5etch2 [114kB]
Fetched 114kB in 0s (437kB/s)
Selecting previously deselected package dhcp.
(Reading database ... 14333 files and directories currently installed.)
Unpacking dhcp (from .../dhcp_2.0pl5-19.5etch2_arm.deb) ...
Setting up dhcp (2.0pl5-19.5etch2) ...
Generating /etc/default/dhcp...
Please note that if you are installing the DHCP server for the first
time you need to configure it first. Please stop (/etc/init.d/dhcp
stop) the DHCP server daemon, edit /etc/dhcpd.conf to suit your needs
and particular configuration, and restart the DHCP server daemon
(/etc/init.d/dhcp start).
You also need to edit /etc/default/dhcp to specify the interfaces dhcpd
should listen to. By default it listens to eth0.
NOTE: dhcpd's messages are being sent to syslog. Look there for
diagnostics messages.
Starting DHCP server: dhcpd failed to start - check syslog for diagnostics.
hackkit:~#
dhcp サーバのコンフィギュレーション
dhcp サーバの停止
まずは、メッセージ通りに dhcpd を止めます。
hackkit:~# /etc/init.d/dhcp stop
Stopping DHCP server: dhcp.
hackkit:~#
/etc/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option domain-name "example.jp";
option domain-name-servers 192.168.1.30, 192.168.1.2;
option ntp-servers 192.168.1.30, 192.168.1.2;
range dynamic-bootp 192.168.1.121 192.168.1.129;
default-lease-time 21600;
max-lease-time 43200;
#host panerina {
# hardware ethernet 00:07:40:e8:12:xx;
# fixed-address 192.168.1.24;
#}
#host psp {
# hardware ethernet 00:02:c7:ce:16:xx;
# fixed-address 192.168.1.52;
#}
}
/etc/default/dhcp
hackkit:/etc# cat /etc/default/dhcp
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp by the maintainer scripts
#
# This is a POSIX shell fragment
#
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES=""
hackkit:/etc#
dhcp サーバの起動
hackkit:/etc# /etc/init.d/dhcp start
Starting DHCP server: dhcpd.
hackkit:/etc#
syslog にエラーが出ていないか確認します。
hackkit:/etc# tail /var/log/daemon.log
:
確認
/var/log/daemon.log を監視しつつ
アドレスを自動取得する設定にした PC などの電源を入れます。
hackkit:/var# tail -f /var/log/daemon.log
:
Nov 4 15:29:32 hackkit dhcpd: DHCPREQUEST for 192.168.1.24 from 00:07:40:e8:12:ea via eth0
Nov 4 15:29:32 hackkit dhcpd: DHCPACK on 192.168.1.24 to 00:07:40:e8:12:ea via eth0
など、dhcpd のログが出力されていれば OK です。
参考ハックの記録
Copyright (C) 2007-2008 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市