gluon-core: add configuration that enables the next_node to be used as dns cache

This commit is contained in:
Christof Schulze 2016-12-30 17:22:22 +01:00
parent 70b116fd61
commit e2e910fb41
4 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,30 @@
DNS-Caching
===========
User experience may be greatly improved when dns is accelerated. Also it
seems like a good idea to keep the number if packages being exchanged
between node and gateway as small as possible. In order to do this, a
dns-cache may be used on a node. The dnsmasq instance listening on port
53 in the node will be re-configured to answer requests, use a list of
upstream servers and a specific cache size if the below options are
added to site.conf All settings are optional, though if no dns server is
set, the configuration will not be altered by gluon-core.
Besides caching dns requests from clients, the next_node-addresses are set to
resolve to a configurable name that may optionally be placed in next_node.name.
::
dns = {
cacheentries = 5000,
servers = { '2001:db8::1', },
},
next_node = {
name = 'nextnode',
ip6 = '2001:db8:8::1',
ip4 = '198.51.100.1',
}
The cache will be initialized during startup. Each cache entry will use roughly
90 Bytes of main memory.

View File

@ -39,3 +39,12 @@ for _, config in ipairs({'wifi24', 'wifi5'}) do
end
need_boolean('poe_passthrough', false)
if need_table('dns', nil, false) then
need_number('dns.cacheentries', false)
need_string_array('dns.servers', false)
end
if need_table('next_node', nil, false) then
need_string_match('next_node.ip6', '^[%x:]+$', false)
need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false)
end

View File

@ -0,0 +1,40 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor()
dnsmasq=uci:get_first("dhcp", "dnsmasq")
uci:set('dhcp', dnsmasq, 'localise_queries', '1')
uci:set('dhcp', dnsmasq, 'localservice', '0')
if site.dns and site.dns.servers then
uci:set('dhcp', dnsmasq, 'server', site.dns.servers)
else
uci:delete('dhcp', dnsmasq, 'server')
end
if site.dns and site.dns.cacheentries then
uci:set('dhcp', dnsmasq, 'cachesize', site.dns.cacheentries)
else
uci:delete('dhcp', dnsmasq, 'cachesize')
end
if site.next_node and site.next_node.name and site.next_node.ip4 then
uci:section('dhcp','domain','nextnode4',{
name=site.next_node.name,
ip=site.next_node.ip4,
})
else
uci:delete('dhcp', 'domain', 'nextnode4')
end
if site.next_node and site.next_node.name and site.next_node.ip6 then
uci:section('dhcp','domain','nextnode6',{
name=site.next_node.name,
ip=site.next_node.ip6,
})
else
uci:delete('dhcp', 'domain', 'nextnode6')
end
uci:save('dhcp')

View File

@ -29,6 +29,10 @@ uci:section('network', 'interface', 'local_node',
}
)
if site.dns and site.dns.servers then
uci:set('network', 'local-node', 'peerdns','0')
end
uci:delete('network', 'local_node_route6')
uci:section('network', 'route6', 'local_node_route6',
{