820-dns-config 822 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site_config'
  3. local uci = require('simple-uci').cursor()
  4. local dns = site.dns or {}
  5. local next_node = site.next_node or {}
  6. local dnsmasq = uci:get_first("dhcp", "dnsmasq")
  7. uci:set('dhcp', dnsmasq, 'localise_queries', true)
  8. uci:set('dhcp', dnsmasq, 'localservice', false)
  9. uci:set('dhcp', dnsmasq, 'server', dns.servers)
  10. uci:set('dhcp', dnsmasq, 'cachesize', dns.cacheentries)
  11. if next_node.name and next_node.ip4 then
  12. uci:section('dhcp', 'domain', 'nextnode4', {
  13. name = next_node.name,
  14. ip = next_node.ip4,
  15. })
  16. else
  17. uci:delete('dhcp', 'domain', 'nextnode4')
  18. end
  19. if next_node.name and next_node.ip6 then
  20. uci:section('dhcp', 'domain', 'nextnode6', {
  21. name = next_node.name,
  22. ip = next_node.ip6,
  23. })
  24. else
  25. uci:delete('dhcp', 'domain', 'nextnode6')
  26. end
  27. uci:save('dhcp')