Skip to content

Commit

Permalink
dhcp: add options for static leases, custom domain names and olsrd-se…
Browse files Browse the repository at this point in the history
…rvices
  • Loading branch information
Noki committed Aug 8, 2023
1 parent feb646a commit a8bfec6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions roles/cfg_openwrt/templates/corerouter/config/dhcp.j2
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,25 @@ config odhcpd 'odhcpd'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'

{% for dhcp_static_lease in dhcp_static_leases | default([]) %}
{% if dhcp_static_lease['name'] is defined and dhcp_static_lease['mac'] is defined and dhcp_static_lease['ip'] is defined %}
config host
option name '{{ dhcp_static_lease['name'] }}'
option mac '{{ dhcp_static_lease['mac'] }}'
option ip '{{ dhcp_static_lease['ip'] }}'
{% if dhcp_static_lease['dns'] is defined %}
option dns '{{ dhcp_static_lease['dns'] }}'
{% endif %}

{% endif %}
{% endfor %}

{% for dhcp_custom_domain_name in dhcp_custom_domain_names | default([]) %}
{% if dhcp_custom_domain_name['name'] is defined and dhcp_custom_domain_name['ip'] is defined %}
config domain
option name '{{ dhcp_custom_domain_name['name'] }}'
option ip '{{ dhcp_custom_domain_name['ip'] }}'

{% endif %}
{% endfor %}
10 changes: 10 additions & 0 deletions roles/cfg_openwrt/templates/corerouter/config/olsrd.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ config LoadPlugin
list hosts '{{ network['prefix'] | ansible.utils.ipaddr(ip_num) | ansible.utils.ipaddr('address') }} {{ host }}'
{% endfor %}
{% endfor %}
{% for dhcp_static_lease in dhcp_static_leases | default([]) %}
{% if dhcp_static_lease['name'] is defined and dhcp_static_lease['ip'] is defined and dhcp_static_lease['olsrd_nameservice'] is defined and dhcp_static_lease['olsrd_nameservice'] == 1 %}
list hosts '{{ dhcp_static_lease['ip'] }} {{ dhcp_static_lease['name'] }}'
{% endif %}
{% endfor %}
{% for olsrd_service in olsrd_services | default([]) %}
{% if olsrd_service['url'] is defined and olsrd_service['protocol'] is defined and olsrd_service['name'] is defined and olsrd_service['url'] | regex_search('.*\\|.*') is none and olsrd_service['protocol'] | regex_search('^(tcp|udp)$') is defined and olsrd_service['name'] | regex_search('^[a-zA-Z0-9 \-]{1,75}$') is defined %}
list service '{{ olsrd_service['url'] }}|{{ olsrd_service['protocol'] }}|{{ olsrd_service['name'] }}'
{% endif %}
{% endfor %}

config LoadPlugin
option accept '0.0.0.0'
Expand Down

0 comments on commit a8bfec6

Please sign in to comment.