I had two problems : 
   1) no PID-file created and
   2) I couldn't assign a NIC to "isc-dhcp-server"aka "dhcpd".

It turned out that the PID-file has to be "/var/run/dhcp-
server/dhcpd.pid". If not, apparmor wouldn't allow the creation of the
PID-file.

And the the file defining the originally installed dhcpd-service script 
("/usr/lib/systemd/system/isc-dhcp-server.service") is having other erroneous 
fixed paths.
 
Solution
---------
So I copied "/usr/lib/systemd/system/isc-dhcp-server.service" to 
"/etc/systemd/system/" and modified it into the one shown below. This solved my 
problems.

[Unit]
Description=ISC DHCP IPv4 server
Documentation=man:dhcpd(8)
Wants=network-online.target
After=network-online.target
After=time-sync.target
ConditionPathExists=/etc/default/isc-dhcp-server
ConditionPathExists=|/etc/ltsp/dhcpd.conf
ConditionPathExists=|/etc/dhcp/dhcpd.conf

[Service]
EnvironmentFile=/etc/default/isc-dhcp-server
RuntimeDirectory=dhcp-server
# The leases files need to be root:dhcpd even when dropping privileges
ExecStart=/bin/sh -ec '\
    CONFIG_FILE=/etc/dhcp/dhcpd.conf; \
    if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; \
    if [ ! -d /var/run/dhcp-server ]; then mkdir -p /var/run/dhcp-server ; 
chown dhcpd:dhcpd /var/run/dhcp-server ; chmod u=rwx,go=rx /var/run/dhcp-server 
; fi; \
    if [ ! "$DHCPDv4_PID" ] ; then DHCPDv4_PID=/var/run/dhcp-server/dhcpd.pid; 
fi; \
    [ -e /var/lib/dhcp/dhcpd.leases ] || touch /var/lib/dhcp/dhcpd.leases; \
    chown root:dhcpd /var/lib/dhcp /var/lib/dhcp/dhcpd.leases; \
    chmod 775 /var/lib/dhcp ; chmod 664 /var/lib/dhcp/dhcpd.leases; \
    exec dhcpd -user dhcpd -group dhcpd -f -4 -pf $DHCPDv4_PID -cf $CONFIG_FILE 
$INTERFACESv4'

[Install]
WantedBy=multi-user.target

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1448657

Title:
  isc-dhcp-server: Can't create PID file /run/dhcp-server/dhcpd.pid:
  Permission denied

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/1448657/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to