綾小路龍之介の素人思考

[debian] isc-dhcp-server で dhcp サーバ

ネットワークの中にdhcpサーバを作っておくことで、ネットワーク内の機器が相互に通信することが可能になる。

dhcpサーバのインストール。今回は isc-dhcp-server を使用。

# apt-get install isc-dhcp-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  isc-dhcp-server-ldap
The following NEW packages will be installed:
  isc-dhcp-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 936 kB of archives.
After this operation, 2,225 kB of additional disk space will be used.
Get:1 http://ftp.jp.debian.org/debian/ wheezy/main isc-dhcp-server i386 4.2.2.dfsg.1-5+deb70u6 [936 kB]
Fetched 936 kB in 0s (1,190 kB/s)
Preconfiguring packages ...
Selecting previously unselected package isc-dhcp-server.
(Reading database ... 22580 files and directories currently installed.)
Unpacking isc-dhcp-server (from .../isc-dhcp-server_4.2.2.dfsg.1-5+deb70u6_i386.deb) ...
Processing triggers for man-db ...
Setting up isc-dhcp-server (4.2.2.dfsg.1-5+deb70u6) ...
Generating /etc/default/isc-dhcp-server...
Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
 failed!
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.

/etc/default/isc-dhcp-server を編集して dhcpサーバの動くネットワークインターフェイスを指定

# grep -v -e '^$' -e '#' /etc/default/isc-dhcp-server
INTERFACES="eth0"

/etc/dhcp/dhcpd.conf を編集。subnetの範囲とdomain-name-serversを設定。ifconfigを見ながら。

# grep -v -e '^$' -e '#' /etc/dhcp/dhcpd.conf
ddns-update-style none;
option domain-name "example.org";
option domain-name-servers 8.8.8.8, 8.8.4.4;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.20.0 netmask 255.255.255.0 {
  option routers 192.168.20.1;
  range 192.168.20.2 192.168.20.100;
}
# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr XXXXXXXXXXXXXXXXX
          inet addr:192.168.20.1  Bcast:192.168.20.255  Mask:255.255.255.0
          inet6 addr: fe80::20d:56ff:fee8:12ca/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:196 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:58047 (56.6 KiB)  TX bytes:1916 (1.8 KiB)
          Interrupt:7

dhcpdの再起動

root@debian:~# /etc/init.d/isc-dhcp-server restart
Stopping ISC DHCP server: dhcpd.
Starting ISC DHCP server: dhcpd.

このままだと外に出ることはできない。同じネットワークの中の機器同士は通信可能。

リファレンス

  1. DHCP_Server - Debian Wiki
  2. DHCP Server Configuration in Debian
  3. debian dhcpd - Google 検索

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-08-04T14:32:01+09:00
  2. Modified: 2010-08-04T14:32:01+09:00
  3. Generated: 2017-03-15T23:09:19+09:00