820-dns-config 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site'
  3. local uci = require('simple-uci').cursor()
  4. local dns = site.dns({})
  5. local next_node = site.next_node({})
  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. uci:delete('firewall', 'client_dns')
  12. if dns.servers then
  13. -- allow inbound traffic for dns from client zone
  14. uci:section('firewall', 'rule', 'client_dns', {
  15. src = 'local_client',
  16. dest_port = '53',
  17. proto = 'tcpudp',
  18. target = 'ACCEPT',
  19. })
  20. end
  21. if next_node.name and next_node.ip4 then
  22. uci:section('dhcp', 'domain', 'nextnode4', {
  23. name = next_node.name,
  24. ip = next_node.ip4,
  25. })
  26. else
  27. uci:delete('dhcp', 'domain', 'nextnode4')
  28. end
  29. if next_node.name and next_node.ip6 then
  30. uci:section('dhcp', 'domain', 'nextnode6', {
  31. name = next_node.name,
  32. ip = next_node.ip6,
  33. })
  34. else
  35. uci:delete('dhcp', 'domain', 'nextnode6')
  36. end
  37. uci:save('dhcp')
  38. uci:save('firewall')