820-dns-config 1003 B

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