Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion data/templates/dhcp-server/kea-dhcp4.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"persist": true,
"name": "{{ lease_file }}"
},
"multi-threading": {
"enable-multi-threading": true
},
{% if client_class is vyos_defined %}
"client-classes": {{ client_class | kea_client_class_json }},
{% endif %}
Expand Down Expand Up @@ -75,16 +78,18 @@
}
},
{% endif %}
{% if any_ping_check is vyos_defined %}
{
"library": "/usr/lib/{{ machine }}-linux-gnu/kea/hooks/libdhcp_ping_check.so",
"parameters": {
"enable-ping-check" : false,
"enable-ping-check" : true,
"min-ping-requests" : 1,
"reply-timeout" : 100,
"ping-cltt-secs" : 60,
"ping-channel-threads" : 0
}
},
{% endif %}
{
"library": "/usr/lib/{{ machine }}-linux-gnu/kea/hooks/libdhcp_lease_cmds.so",
"parameters": {}
Expand Down
2 changes: 1 addition & 1 deletion python/vyos/kea.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def kea_parse_options(config):


def kea_parse_subnet(subnet, config):
out = {'subnet': subnet, 'id': int(config['subnet_id']), 'user-context': {}}
out = {'subnet': subnet, 'id': int(config['subnet_id']), 'user-context': {'enable-ping-check': False}}

if 'option' in config:
out['option-data'] = kea_parse_options(config['option'])
Expand Down
12 changes: 9 additions & 3 deletions python/vyos/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def kea_shared_network_json(shared_networks):
'name': name,
'authoritative': ('authoritative' in config),
'subnet4': [],
'user-context': {}
'user-context': {'enable-ping-check': False}
}

if 'dynamic_dns_update' in config:
Expand All @@ -1030,15 +1030,21 @@ def kea_shared_network_json(shared_networks):
if 'bootfile_server' in config['option']:
network['next-server'] = config['option']['bootfile_server']

if 'ping_check' in config:
network['user-context']['enable-ping-check'] = True
subnet_ping_check = False

if 'subnet' in config:
for subnet, subnet_config in config['subnet'].items():
if 'disable' in subnet_config:
continue

if 'ping_check' in subnet_config:
subnet_ping_check = True

network['subnet4'].append(kea_parse_subnet(subnet, subnet_config))

if 'ping_check' in config or subnet_ping_check:
network['user-context']['enable-ping-check'] = True

out.append(network)

return dumps(out, indent=4)
Expand Down
4 changes: 4 additions & 0 deletions src/conf_mode/service_dhcp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from vyos.template import render
from vyos.utils.dict import dict_search
from vyos.utils.dict import dict_search_args
from vyos.utils.dict import dict_search_recursive
from vyos.utils.file import chmod_775
from vyos.utils.file import makedir
from vyos.utils.file import write_file
Expand Down Expand Up @@ -226,6 +227,9 @@ def get_config(config=None):
no_tag_node_value_mangle=True,
)

if bool(list(dict_search_recursive(dhcp, 'ping_check'))):
dhcp['any_ping_check'] = True

return dhcp

def verify_ddns_domain_servers(domain_type, domain):
Expand Down
Loading