gluon-firmware/package/gluon-core/luasrc/lib/gluon/upgrade/820-dns-config

48 lines
1.1 KiB
Lua
Executable File

#!/usr/bin/lua
local site = require 'gluon.site'
local uci = require('simple-uci').cursor()
local dns = site.dns({})
local next_node = site.next_node({})
local dnsmasq = uci:get_first("dhcp", "dnsmasq")
uci:set('dhcp', dnsmasq, 'localise_queries', true)
uci:set('dhcp', dnsmasq, 'localservice', false)
uci:set('dhcp', dnsmasq, 'server', dns.servers)
uci:set('dhcp', dnsmasq, 'cachesize', dns.cacheentries)
uci:delete('firewall', 'client_dns')
if dns.servers then
-- allow inbound traffic for dns from client zone
uci:section('firewall', 'rule', 'client_dns', {
src = 'local_client',
dest_port = '53',
proto = 'tcpudp',
target = 'ACCEPT',
})
end
if next_node.name and next_node.ip4 then
uci:section('dhcp', 'domain', 'nextnode4', {
name = next_node.name,
ip = next_node.ip4,
})
else
uci:delete('dhcp', 'domain', 'nextnode4')
end
if next_node.name and next_node.ip6 then
uci:section('dhcp', 'domain', 'nextnode6', {
name = next_node.name,
ip = next_node.ip6,
})
else
uci:delete('dhcp', 'domain', 'nextnode6')
end
uci:save('dhcp')
uci:save('firewall')