summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index e03a04a4d..3a095b618 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -28,12 +28,16 @@ from vyos.config import Config
from vyos import ConfigError
config_file = r'/etc/dhcp/dhcpd.conf'
+lease_file = r'/config/dhcpd.leases'
daemon_config_file = r'/etc/default/isc-dhcp-server'
# Please be careful if you edit the template.
config_tmpl = """
### Autogenerated by dhcp_server.py ###
+# For options please consult the following website:
+# https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html
+
log-facility local7;
{% if hostfile_update %}
@@ -103,7 +107,7 @@ failover peer "{{ subnet.failover_name }}" {
{% endif -%}
{% endfor %}
-# Shared network configrations
+# Shared network configration(s)
{% for network in shared_network %}
{%- if not network.disabled -%}
shared-network {{ network.name }} {
@@ -206,22 +210,14 @@ daemon_tmpl = """
# sourced by /etc/init.d/isc-dhcp-server
-# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
DHCPD_CONF=/etc/dhcp/dhcpd.conf
-
-# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
DHCPD_PID=/var/run/dhcpd.pid
-
-# Additional options to start dhcpd with.
-# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
-OPTIONS="-lf /config/dhcpd.leases"
-
-# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
-# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
+OPTIONS="-4 -lf {{ lease_file }}"
INTERFACES=""
"""
default_config_data = {
+ 'lease_file': lease_file,
'disabled': False,
'ddns_enable': False,
'global_parameters': [],
@@ -764,6 +760,10 @@ def apply(dhcp):
if os.path.exists(daemon_config_file):
os.unlink(daemon_config_file)
else:
+ # If our file holding DHCP leases does yet not exist - create it
+ if not os.path.exists(lease_file):
+ os.mknod(lease_file)
+
os.system('sudo systemctl restart isc-dhcp-server.service')
return None