2015-08-17 22:53:40 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
|
|
|
local sysconfig = require 'gluon.sysconfig'
|
2017-02-10 08:32:39 +00:00
|
|
|
local sysctl = require 'gluon.sysctl'
|
2017-01-17 22:57:39 +00:00
|
|
|
local util = require 'gluon.util'
|
2016-05-01 12:21:20 +00:00
|
|
|
|
2017-01-19 11:51:04 +00:00
|
|
|
local uci = require('simple-uci').cursor()
|
2015-08-17 22:53:40 +00:00
|
|
|
|
|
|
|
|
2017-01-17 22:57:39 +00:00
|
|
|
local interfaces = uci:get('network', 'client', 'ifname') or {}
|
2015-08-17 22:53:40 +00:00
|
|
|
|
2017-01-17 22:57:39 +00:00
|
|
|
if type(interfaces) == 'string' then
|
|
|
|
local ifname = interfaces
|
|
|
|
interfaces = {}
|
2017-01-19 15:13:20 +00:00
|
|
|
for iface in ifname:gmatch('%S+') do
|
2017-01-17 22:57:39 +00:00
|
|
|
util.add_to_set(interfaces, iface)
|
2016-11-30 19:29:25 +00:00
|
|
|
end
|
2015-08-17 22:53:40 +00:00
|
|
|
end
|
|
|
|
|
2016-05-01 12:21:20 +00:00
|
|
|
if sysconfig.lan_ifname and not ifname and not uci:get_bool('network', 'mesh_lan', 'auto') then
|
2017-01-19 15:13:20 +00:00
|
|
|
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
|
2017-01-17 22:57:39 +00:00
|
|
|
util.add_to_set(interfaces, lanif)
|
2016-11-30 19:29:25 +00:00
|
|
|
end
|
2016-05-01 12:21:20 +00:00
|
|
|
end
|
|
|
|
|
2017-02-10 08:44:23 +00:00
|
|
|
util.add_to_set(interfaces, 'local-port')
|
|
|
|
|
|
|
|
|
2017-02-10 08:32:39 +00:00
|
|
|
uci:delete('network', 'client')
|
|
|
|
uci:section('network', 'interface', 'client', {
|
|
|
|
type = 'bridge',
|
|
|
|
ifname = interfaces,
|
|
|
|
proto = 'none',
|
|
|
|
auto = true,
|
|
|
|
ipv6 = false,
|
|
|
|
macaddr = sysconfig.primary_mac,
|
|
|
|
})
|
2017-01-17 22:57:39 +00:00
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
uci:save('network')
|
2016-05-01 12:21:20 +00:00
|
|
|
|
2015-08-17 22:53:40 +00:00
|
|
|
|
2017-02-10 08:32:39 +00:00
|
|
|
uci:delete('firewall', 'client')
|
|
|
|
uci:section('firewall', 'zone', 'client', {
|
|
|
|
name = 'client',
|
|
|
|
network = {'client'},
|
|
|
|
input = 'DROP',
|
|
|
|
output = 'DROP',
|
|
|
|
forward = 'DROP',
|
|
|
|
})
|
|
|
|
|
|
|
|
uci:save('firewall')
|
|
|
|
|
|
|
|
|
2016-11-30 19:29:25 +00:00
|
|
|
local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
|
2017-01-19 11:51:04 +00:00
|
|
|
uci:set('dhcp', dnsmasq, 'boguspriv', false)
|
|
|
|
uci:set('dhcp', dnsmasq, 'localise_queries', false)
|
|
|
|
uci:set('dhcp', dnsmasq, 'rebind_protection', false)
|
2016-11-30 19:29:25 +00:00
|
|
|
|
|
|
|
uci:delete('dhcp', 'client')
|
2017-02-10 07:16:27 +00:00
|
|
|
uci:section('dhcp', 'dhcp', 'client', {
|
|
|
|
interface = 'client',
|
|
|
|
ignore = true,
|
|
|
|
})
|
2016-11-30 19:29:25 +00:00
|
|
|
|
|
|
|
uci:save('dhcp')
|
2017-02-10 08:32:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
sysctl.set('net.ipv6.conf.br-client.forwarding', 0)
|