Ubuntu

Ubuntu 12.04 サーバー再構築(8) dhcpdの導入

さて、dhcpdを入れよう。
と思ったら、色々なパッケージがあるみたい。

広告


isc-dhcp-server

リンク切れ http://packages.debian.org/ja/squeeze/isc-dhcp-server
これは Internet Software Consortium 製 DHCP 実装由来のサーバです。より詳し い情報は、http://www.isc.org を参照してください。
動的ホスト設定プロトコル (DHCP) は BOOTP に似たプロトコルです (実際、dhcpd には bootpd の機能の多くが含まれています)。クライアントマシンに IP アドレス を “リース” し、クライアントマシンのネットワークを自動設定できます。
本サーバは複数の ethernet インターフェースを扱うことができます。

dhcp3-server

リンク切れ http://packages.debian.org/ja/squeeze/dhcp3-server
これは Internet Software Consortium 製 DHCP 実装由来のサーバです。より詳し い情報は、http://www.isc.org を参照してください。
動的ホスト設定プロトコル (DHCP) は BOOTP に似たプロトコルです (実際、dhcpd には bootpd の機能の多くが含まれています)。クライアントマシンに IP アドレス を “リース” し、クライアントマシンのネットワークを自動設定できます。
本サーバは複数の ethernet インターフェースを扱うことができます。
これは v3 DHCP パッケージから、新式の DHCP パッケージへの移行を助けるダミー パッケージです。
本ダミーパッケージは squeeze へアップグレードした後には安全に削除することが できます。

udhcpd

リンク切れ http://packages.debian.org/ja/squeeze/udhcpd
Provides the busybox DHCP server implementation
Busybox contains a very small yet fully function RFC compliant DHCP server formerly known as udhcpd.
This package contains the glue to use the busybox udhcpd as DHCP server in the system by providing the appropriate symbolic links and scripts.

dhcp3-serverは除外。

udhcpdはBusyBoxのもので軽量っぽい。
http://ja.wikipedia.org/wiki/BusyBox

isc-dhcp-serverはちょっと大げさなのかもしれない。

→ 結論。サーバークラッシュ前がisc-dhcp-serverだったので、多分、設定も慣れてるからそちらで。


■isc-dhcp-serverのインストール

$ sudo apt-get install isc-dhcp-server

■設定の前に

さて設定・・・と思ったら、こんな感じ。どっちなの?と。

$ ll /etc/dhcp*
/etc/dhcp:
合計 32
drwxr-xr-x 4 root root 4096 5月 26 07:42 ./
drwxr-xr-x 133 root root 12288 5月 26 07:42 ../
drwxr-xr-x 2 root root 4096 5月 22 01:11 dhclient-enter-hooks.d/
drwxr-xr-x 2 root root 4096 5月 22 01:11 dhclient-exit-hooks.d/
-rw-r–r– 1 root root 1791 11月 8 2012 dhclient.conf
-rw-r–r– 1 root root 3602 11月 8 2012 dhcpd.conf

/etc/dhcp3:
合計 20
drwxr-xr-x 3 root root 4096 5月 22 01:09 ./
drwxr-xr-x 133 root root 12288 5月 26 07:42 ../
drwxr-xr-x 2 root root 4096 5月 22 01:11 dhclient-enter-hooks.d/

念のため、確認。

$ sudo apt-file search dhcpd.conf
cfg2-server: /usr/share/bcfg2/Hostbase/repo/dhcpd.conf.head
di-netboot-assistant: /usr/share/doc/di-netboot-assistant/examples/dhcpd.conf.multiarch.gz
di-netboot-assistant: /usr/share/doc/di-netboot-assistant/examples/dhcpd.conf.simple.gz
di-netboot-assistant: /usr/share/doc/di-netboot-assistant/examples/dhcpd.conf.upstream
elilo: /usr/share/doc/elilo/examples/netboot/dhcpd.conf
fai-doc: /usr/share/doc/fai-doc/examples/etc/dhcpd.conf
fai-doc: /usr/share/doc/fai-doc/examples/simple/files/etc/dhcp3/dhcpd.conf/FAISERVER
initramfs-tools-tcos: /usr/share/doc/initramfs-tools-tcos/examples/dhcpd.conf
isc-dhcp-server: /etc/dhcp/dhcpd.conf
isc-dhcp-server: /usr/share/doc/isc-dhcp-server/examples/dhcpd.conf
isc-dhcp-server: /usr/share/man/man5/dhcpd.conf.5.gz
logwatch: /usr/share/logwatch/default.conf/services/dhcpd.conf
ltsp-server: /usr/share/doc/ltsp-server/examples/dhcpd.conf
ltsp-server-standalone: /etc/ltsp/dhcpd.conf
manpages-ja: /usr/share/man/ja/man5/dhcpd.conf.5.gz
mythbuntu-diskless-server-standalone: /etc/ltsp/dhcpd.conf
udhcpd: /etc/udhcpd.conf
udhcpd: /usr/share/man/man5/udhcpd.conf.5.gz
zentyal-dhcp: /etc/init/zentyal.dhcpd.conf
zentyal-dhcp: /usr/share/zentyal/stubs/dhcp/dhcpd.conf.mas

$ find /etc -name \* | xargs grep dhcpd.conf
/etc/init/isc-dhcp-server.conf: if [ -f /etc/ltsp/dhcpd.conf ]; then
/etc/init/isc-dhcp-server.conf: CONFIG_FILE=/etc/ltsp/dhcpd.conf
/etc/init/isc-dhcp-server.conf: CONFIG_FILE=/etc/dhcp/dhcpd.conf
/etc/init/isc-dhcp-server.conf: if [ -f /etc/ltsp/dhcpd.conf ]; then
/etc/init/isc-dhcp-server.conf: CONFIG_FILE=/etc/ltsp/dhcpd.conf
/etc/init/isc-dhcp-server.conf: CONFIG_FILE=/etc/dhcp/dhcpd.conf

どうやら、この /etc/dhcp/dhcpd.conf でいいらしい。

■設定

$ sudo vi /etc/dhcp/dhcpd.conf
色々書いたので、まるごとココに。

#
# Sample configuration file for ISC dhcpd for Debian
#
# Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as
# configuration file instead of this file.
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "hogeserver.hogeddns.jp";
option domain-name-servers 172.16.nnn.1;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

#-----------------------------------------
# This is a my network subnet declaration.
#-----------------------------------------
subnet 172.16.0.0 netmask 255.255.0.0 {

        # --- default gateway
option routers 172.16.nnn.1;

# --- WINS server
option netbios-name-servers 172.16.nnn.nnn;

# --- NTP server
option ntp-servers 172.16.nnn.nnn;

option time-offset -18000; # Eastern Standard Time

# --- Lease range setting
range 172.16.nnn.st 172.16.nnn.ed;

# --- Fixed address
host hogeclient {
hardware ethernet nn:nn:nn:nn:nn:nn;
fixed-address 172.16.nnn.nn1;
}

host hogeprinter {
hardware ethernet nn:nn:nn:nn:nn:nn;
fixed-address 172.16.nnn.nn2;
}

host iphone_hogeuser {
hardware ethernet nn:nn:nn:nn:nn:nn;
fixed-address 172.16.nnn.nn3;
}

host ipad_hogeuser {
hardware ethernet nn:nn:nn:nn:nn:nn;
fixed-address 172.16.nnn.nn4;
}

        # --- for Nintendo 3DS
if option host-name = "Nintendo 3DS" {
ddns-hostname = concat ("Nintendo3DS", binary-to-ascii (16, 8, "-", substring (hardware, 1, 6)));
}

}

bind9との連携に関わる部分はbind9をインストールしてから追記。
まずは、dhcpdとWINSだけを運用。

■動作確認

$ sudo service isc-dhcp-server restart

ルーターのDHCPサーバー機能を解除してから、Windows7のDOS窓で以下を実行。

DOS> ipconfig /release “ローカル エリア接続”
DOS> ipconfig /renew
DOS> ipconfig /all

Windows IP 構成

ホスト名 . . . . . . . . . . . . : hogeclient
プライマリ DNS サフィックス . . . . . . . :
ノード タイプ . . . . . . . . . . . . : ピア ツー ピア
IP ルーティング有効 . . . . . . . . : いいえ
WINS プロキシ有効 . . . . . . . . : いいえ
DNS サフィックス検索一覧 . . . . . . : hogehoge.hogeddns.jp

イーサネット アダプター ローカル エリア接続:

接続固有の DNS サフィックス . . . : hogehoge.hogeddns.jp
説明. . . . . . . . . . . . . . . : Realtek PCIe GBE Family Controller
物理アドレス. . . . . . . . . . . : nn-nn-nn-nn-nn-nn
DHCP 有効 . . . . . . . . . . . . : はい
自動構成有効. . . . . . . . . . . : はい
IPv6 アドレス . . . . . . . . . . . : nnnn:nnnn:nnnn:nnnn:nnnn:nnnn:nnnn:nnnn(
優先)
一時 IPv6 アドレス. . . . . . . . . : nnnn:nnnn:nnnn:nnnn:nnnn:nnnn:nnnn:nnnn(
優先)
リンクローカル IPv6 アドレス. . . . : nnnn::nnnn:nnnn:nnnn:nnnn%28(優先)
IPv4 アドレス . . . . . . . . . . : 172.16.nnn.nn1(優先)
サブネット マスク . . . . . . . . : 255.255.0.0
リース取得. . . . . . . . . . . . : 2013年5月26日 10:07:19
リースの有効期限. . . . . . . . . : 2013年5月26日 10:17:18
デフォルト ゲートウェイ . . . . . : nnnn::nnnn:nnnn:nnnn%28
172.16.nnn.1
DHCP サーバー . . . . . . . . . . : 172.16.nnn.nnn
DNS サーバー. . . . . . . . . . . : 172.16.nnn.1
プライマリ WINS サーバー. . . . . : 172.16.nnn.nnn
NetBIOS over TCP/IP . . . . . . . : 有効

狙い通り。

広告

コメントはこちらから お気軽にどうぞ ~ 投稿に関するご意見・感想・他