Package: isc-dhcp-server
Version: 4.1.1-P1-15
Severity: normal

It appears to me like it's pretty hard to install isc-dhcp and set it
up according to the type of server one wants to use; e.g. setting it
up as a DHCPv6 server specifically, or having a DHCPv6 server
alongside a DHCPv4 server.

I think a little more could be done to facilitate such setups and
avoid people editing the isc-dhcp-server init script (and potentially
losing their changes in an update).

It's far from ideal I realize, but attached is a patch which attempts
to make this a little simpler: setting up a DHCPv6 server from there
is a matter of symlinking the init script or copying it to a new name
and editing a file /etc/default/<basename_of_init_script>. Setting up
the mode of the server (to serve v4 or v6 addresses) is set as an
additional option in that file.

-- System Information:
Debian Release: squeeze/sid
  APT prefers natty-updates
  APT policy: (500, 'natty-updates'), (500, 'natty-security'), (500, 'natty')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.37-12-generic (SMP w/4 CPU cores)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash


Mathieu Trudel-Lapierre <mathieu...@ubuntu.com>
Freenode: cyphermox, Jabber: mathieu...@gmail.com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93
=== modified file 'debian/isc-dhcp-server.init.d'
--- debian/isc-dhcp-server.init.d	2010-11-09 17:40:49 +0000
+++ debian/isc-dhcp-server.init.d	2011-02-01 21:40:42 +0000
@@ -15,11 +15,12 @@
 ### END INIT INFO
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DEFAULTS_FILE=/etc/default/`basename $0`
 
 test -f /usr/sbin/dhcpd || exit 0
 
 # It is not safe to start if we don't have a default configuration...
-if [ ! -f /etc/default/isc-dhcp-server ]; then
+if [ ! -f $DEFAULTS_FILE ]; then
 	echo "/etc/default/isc-dhcp-server does not exist! - Aborting..."
 	echo "Run 'dpkg-reconfigure isc-dhcp-server' to fix the problem."
 	exit 0
@@ -28,8 +29,8 @@
 . /lib/lsb/init-functions
 
 # Read init script configuration (so far only interfaces the daemon
-# should listen on.)
-[ -f /etc/default/isc-dhcp-server ] && . /etc/default/isc-dhcp-server
+# should listen on and DHCP mode (v4 or v6).)
+[ -f $DEFAULTS_FILE ] && . $DEFAULTS_FILE
 
 NAME=dhcpd
 DESC="ISC DHCP server"
@@ -37,10 +38,10 @@
 
 test_config()
 {
-	if ! /usr/sbin/dhcpd -t -q > /dev/null 2>&1; then
+	if ! /usr/sbin/dhcpd $DHCPMODE -t -q > /dev/null 2>&1; then
 		echo "dhcpd self-test failed. Please fix the config file."
 		echo "The error was: "
-		/usr/sbin/dhcpd -t
+		/usr/sbin/dhcpd $DHCPMODE -t
 		exit 1
 	fi
 }
@@ -66,7 +67,7 @@
 		test_config
 		log_daemon_msg "Starting $DESC" "$NAME"
 		start-stop-daemon --start --quiet --pidfile $DHCPDPID \
-			--exec /usr/sbin/dhcpd -- -q $INTERFACES
+			--exec /usr/sbin/dhcpd -- $DHCPMODE -q $INTERFACES
 		sleep 2
 
 		if check_status -q; then

=== modified file 'debian/isc-dhcp-server.postinst'
--- debian/isc-dhcp-server.postinst	2010-11-09 17:40:49 +0000
+++ debian/isc-dhcp-server.postinst	2011-02-01 21:40:42 +0000
@@ -43,6 +43,11 @@
 # This is a POSIX shell fragment
 #
 
+# DHCP mode to use:
+#  -4  -  standard IPv4 DHCP (default)
+#  -6  -  DHCPv6
+DHCPMODE="-4"
+
 # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
 #	Separate multiple interfaces with spaces, e.g. "eth0 eth1".
 INTERFACES=""
@@ -82,6 +87,12 @@
 	fi
 fi
 
+# ISC DHCP 4 introduces DHCPv6. That also means we need to ship an extra
+# lease file.
+if [ ! -e /var/lib/dhcp/dhcpd6.leases ]; then
+	touch /var/lib/dhcp/dhcpd6.leases
+fi
+
 [ -x /sbin/restorecon ] && restorecon /var/lib/dhcp/dhcpd.leases
 
 init_script_error_handler()

=== modified file 'debian/isc-dhcp-server.postrm'
--- debian/isc-dhcp-server.postrm	2010-06-15 23:20:30 +0000
+++ debian/isc-dhcp-server.postrm	2011-02-01 21:40:42 +0000
@@ -12,6 +12,7 @@
     purge)
 	# Remove database
 	rm -f /var/lib/dhcp/dhcpd.leases /var/lib/dhcp/dhcpd.leases~
+	rm -f /var/lib/dhcp/dhcpd6.leases /var/lib/dhcp/dhcpd6.leases~
 
 	# Remove database directory
 	if [ -d /var/lib/dhcp ]; then

Reply via email to