読者です 読者をやめる 読者になる 読者になる

ubuntuにdhcpをインストール

覚書。

パッケージのインストール

普通にaptitude

$ sudo aptitude install dhcp3-server

 
インストールは成功したが、起動に失敗

dhcp3-server (3.1.1-5ubuntu8.1) を設定しています ...
Generating /etc/default/dhcp3-server...
* Reloading AppArmor profiles ... [ OK ]
* Starting DHCP server dhcpd3 * check syslog for diagnostics.
[fail]
invoke-rc.d: initscript dhcp3-server, action "start" failed.

syslogを見ると

$ sudo grep dhcpd /var/log/syslog
Nov 1 17:10:43 ubuntu904desktop kernel: [24541.197058] type=1505 audit(1257063043.795:17): operation="profile_load" name="/usr/sbin/dhcpd3" name2="default" pid=10329
Nov 1 17:10:44 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:10:44 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:10:44 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:10:44 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:10:44 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:10:44 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:10:44 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:10:44 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:10:44 ubuntu904desktop kernel: [24541.488969] warning: `dhcpd3' uses 32-bit capabilities (legacy support in use)
Nov 1 17:10:44 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:10:44 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:10:44 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:10:44 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:10:44 ubuntu904desktop dhcpd: Wrote 0 leases to leases file.
Nov 1 17:10:44 ubuntu904desktop dhcpd:
Nov 1 17:10:44 ubuntu904desktop dhcpd: No subnet declaration for eth1 (192.168.1.3).
Nov 1 17:10:44 ubuntu904desktop dhcpd: ** Ignoring requests on eth1. If this is not what
Nov 1 17:10:44 ubuntu904desktop dhcpd: you want, please write a subnet declaration
Nov 1 17:10:44 ubuntu904desktop dhcpd: in your dhcpd.conf file for the network segment
Nov 1 17:10:44 ubuntu904desktop dhcpd: to which interface eth1 is attached. **
Nov 1 17:10:44 ubuntu904desktop dhcpd:
Nov 1 17:10:44 ubuntu904desktop dhcpd:
Nov 1 17:10:44 ubuntu904desktop dhcpd: Not configured to listen on any interfaces!

ネットワーク周りの設定が自動でうまく作れなかった模様。
ちなみにvmware向けに配布されていたubuntu9.04のイメージをそのまま使ったら、
普段使いのNICがeth1になった。
細かいところは見ていないが、まあその辺が原因かと憶測。

まあ起動は設定完了後にできればいいのでとりあえず設定編集へ。

設定ファイルの編集

$ sudo vi /etc/dhcp3/dhcpd.conf

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.110; # 割り当て範囲
option routers 192.168.1.1; # ゲートウェイ
option broadcast-address 192.168.1.255; #Bcast
default-lease-time 600; # リース時間(初期値)
max-lease-time 7200; # 最大リース時間
option domain-name-servers 192.168.1.1; # DNS
}

大体こんな感じのはず。

起動

$ sudo /etc/init.d/dhcp3-server start

syslogにも特に文句が出なかったので動いているはず

$ sudo grep dhcpd /var/log/syslog
(前略)
Nov 1 17:25:20 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:25:20 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:25:20 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:25:20 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:25:20 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:25:20 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:25:20 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:25:20 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:25:20 ubuntu904desktop dhcpd: Internet Systems Consortium DHCP Server V3.1.1
Nov 1 17:25:20 ubuntu904desktop dhcpd: Copyright 2004-2008 Internet Systems Consortium.
Nov 1 17:25:20 ubuntu904desktop dhcpd: All rights reserved.
Nov 1 17:25:20 ubuntu904desktop dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Nov 1 17:25:20 ubuntu904desktop dhcpd: Wrote 0 leases to leases file.