■ DHCPserver のインストール

DHCPサーバのバイナリーパッケージ dhcpd をインストールします。

# apt-get install dhcpd
■ /etc/dhcpd.conf の編集

新ネットワーク構成図に従い編集します。クライアントaiko,hanako,tarou,takuyaのIPは固定それ以外は動的に割り付けることにしました。eth0は外側、eth1は内側です。外側に影響を与えない為にこうしてみました。

# ------------ eth0 ------------------------------------
subnet xx1.xx2.xx3.0 netmask 255.255.255.0 {
}

外側からの「DHCPREQUEST」を検出しても「DHCPNAK」を返すのは確認しましたが、もっと良い方法はないのか? 外側から「DHCPDISCOVER」をブロードキャストしてきてもまったく応えないような設定はないのか(-_-;)、、、わかんないから当面この設定でやります(^^;)。
# vi /etc/dhcpd.conf

#---dhcpd.conf---
option domain-name "tesut.com";
option domain-name-servers 192.168.1.254;

option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;

# ------------ eth0 ------------------------------------
subnet xx1.xx2.xx3.0 netmask 255.255.255.0 {
}

# ------------ eth1 ------------------------------------
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.1.21 192.168.1.29;
option broadcast-address 192.168.2.255;
option routers 192.168.1.1;
}
host hanako{
hardware ethernet 00:40:xx:xx:xx:xx;
fixed-address 192.168.1.11;
server-name "hanako.test.com";
}
host tarou{
hardware ethernet 00:90:xx:xx:xx:xx;
fixed-address 192.168.1.12;
server-name "tarou.test.com";
}
host takuya{
hardware ethernet 00:90:xx:xx:xx:xx;
fixed-address 192.168.1.13;
server-name "takuya.test.com";
}
host aiko{
hardware ethernet 00:40:xx:xx:xx:xx;
fixed-address 192.168.1.14;
server-name "aiko.test.com";
}

■ /etc/init.d/dhcp の編集

# vi /etc/init.d/dhcp

run_dhcpd=0..............を
run_dhcpd=1..............に


■ クライアントから確認

クライアントから ipconfig などで確認してみましょう。IP固定割付などはうまくいっていますか。

C:\ipconfig

Windows 2000 IP Configuration

Ethernet adapter ローカル エリア接続:


Connection-specific DNS Suffix . : test.com
IP Address. . . . . . . . . . . . : 192.168.1.14
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1

■ /etc/init.d/dhcp の編集 NO.2

やはり、「外側からの「DHCPREQUEST」を検出しても「DHCPNAK」を返すのは確認しましたが、」は、気になっておりました。で、こんな具合にしてみました。

DHCPDPID=/var/run/dhcpd.pid

case "$1" in
start)
start-stop-daemon --start --quiet --pidfile $DHCPDPID \
--exec /usr/sbin/dhcpd -- -cf /etc/dhcpd.conf eth1
;;
stop)
start-stop-daemon --stop --quiet --pidfile $DHCPDPID
;;
restart)
start-stop-daemon --stop --quiet --pidfile $DHCPDPID
sleep 2
start-stop-daemon --start --quiet --pidfile $DHCPDPID \
--exec /usr/sbin/dhcpd -- -cf /etc/dhcpd.conf eth1
;;
*)
echo "Usage: /etc/init.d/dhcp {start|stop|restart}"
exit 1
esac

exit 0

そしてこうすると eth1 だけが動きました。

# /etc/init.d/dhcp start

Internet Software Consortium DHCP Server 2.0pl4
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html

Listening on LPF/eth1/00:40:26:cc:62:5d/192.168.2.0
Sending on LPF/eth1/00:40:26:cc:62:5d/192.168.2.0
Sending on Socket/fallback/fallback-net

これで syslog にこんなのが残らなくなりました。て言うか迷惑かけていたのかなぁ(^^;)

Jan 23 21:10:31 ns dhcpd-2.2.x: DHCPDISCOVER from 00:50:c9:17:0b:fe via eth0