diff --git a/DEVELOPER.md b/DEVELOPER.md index 7afc7596c..2df097994 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -246,6 +246,55 @@ airos_dfs_reset: daytime_limit: "2-7" ``` +#### dhcp.yml + +This optional file allows to set static dhcp leases and custom domain names. The syntax is as follows: + +```yml +--- +dhcp_static_leases: +- name: hostname1 + mac: AA:AA:AA:AA:AA:AA + ip: 10.10.10.1 +- name: hostname2 + mac: BB:BB:BB:BB:BB:BB + ip: 10.10.10.2 + dns: 1 +- name: webcam1 + mac: CC:CC:CC:CC:CC:CC + ip: 10.10.10.3 + dns: 1 + olsrd_nameservice: 1 +- name: webcam2 + mac: DD:DD:DD:DD:DD:DD + ip: 10.10.10.4 + dns: 1 + olsrd_nameservice: 1 +dhcp_custom_domain_names: +- name: unifi + ip: 10.10.10.2 +``` + +A hostname, mac address and ip is required. The option `dns: 1` ensures that the entry is added without the `.lan` suffix. +The option `olsrd_nameservice` also announces the host via the olsrd nameservice, which is useful for olsrd services. + +#### olsrd.yml + +This optional file allows to announce services via olsrd. The syntax is as follows: + +```yml +--- +olsrd_services: +- name: Webcam 1 + protocol: tcp + url: http://webcam1.olsr:80/ +- name: Webcam 2 + protocol: tcp + url: http://webcam2.olsr:80/ +``` + +The name, protocol and URL are mandatory. The name has a length constraint of 75 characters. Special chars should not be used. + ## host_vars/ The `host-vars`-dir contains a host directory for every OpenWrt-device. diff --git a/roles/cfg_openwrt/templates/corerouter/config/dhcp.j2 b/roles/cfg_openwrt/templates/corerouter/config/dhcp.j2 index dacbcdf4e..2e044b1b9 100644 --- a/roles/cfg_openwrt/templates/corerouter/config/dhcp.j2 +++ b/roles/cfg_openwrt/templates/corerouter/config/dhcp.j2 @@ -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 %} diff --git a/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 b/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 index 59880bdc4..903052350 100644 --- a/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 +++ b/roles/cfg_openwrt/templates/corerouter/config/olsrd.j2 @@ -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'