2014-07-07 22:22:48 +02:00
|
|
|
#!/usr/bin/lua
|
2014-01-21 03:05:42 +01:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
|
|
local sysctl = require 'gluon.sysctl'
|
|
|
|
local uci = require('luci.model.uci').cursor()
|
2014-01-21 03:05:42 +01:00
|
|
|
|
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:delete('batman-adv', 'bat0')
|
|
|
|
uci:section('batman-adv', 'mesh', 'bat0',
|
|
|
|
{
|
|
|
|
orig_interval = 5000,
|
|
|
|
gw_mode = 'client',
|
2014-10-05 15:24:58 +02:00
|
|
|
multicast_mode = 0,
|
2014-07-07 22:22:48 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
uci:save('batman-adv')
|
|
|
|
uci:commit('batman-adv')
|
2014-01-21 03:05:42 +01:00
|
|
|
|
2014-01-25 02:09:35 +01:00
|
|
|
|
2014-08-08 15:50:52 +02:00
|
|
|
if not uci:get('network', 'client') then
|
|
|
|
local ifname
|
|
|
|
|
|
|
|
if sysconfig.lan_ifname then
|
|
|
|
ifname = sysconfig.lan_ifname .. ' bat0'
|
|
|
|
else
|
|
|
|
ifname = 'bat0'
|
|
|
|
end
|
|
|
|
|
|
|
|
uci:section('network', 'interface', 'client',
|
|
|
|
{
|
|
|
|
ifname = ifname,
|
|
|
|
type = 'bridge',
|
|
|
|
proto = 'dhcpv6',
|
|
|
|
reqprefix = 'no',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-09-09 11:29:51 +02:00
|
|
|
uci:set('network', 'client', 'igmp_snooping', 0)
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:set('network', 'client', 'macaddr', sysconfig.primary_mac)
|
|
|
|
uci:set('network', 'client', 'peerdns', 1)
|
2014-01-21 03:05:42 +01:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:delete('network', 'bat0')
|
|
|
|
uci:section('network', 'interface', 'bat0',
|
|
|
|
{
|
|
|
|
ifname = 'bat0',
|
|
|
|
proto = 'none',
|
|
|
|
macaddr = sysconfig.primary_mac,
|
|
|
|
}
|
|
|
|
)
|
2014-01-21 05:17:00 +01:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:save('network')
|
|
|
|
uci:commit('network')
|
2014-01-21 03:05:42 +01:00
|
|
|
|
2014-07-14 17:53:41 +02:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:delete('firewall', 'client')
|
|
|
|
uci:section('firewall', 'zone', 'client',
|
|
|
|
{
|
|
|
|
name = 'client',
|
|
|
|
network = {'client'},
|
|
|
|
input = 'ACCEPT',
|
|
|
|
output = 'ACCEPT',
|
|
|
|
forward = 'REJECT',
|
|
|
|
}
|
|
|
|
)
|
2014-07-14 17:53:41 +02:00
|
|
|
|
2014-07-14 18:23:56 +02:00
|
|
|
uci:section('firewall', 'rule', 'client_dns',
|
2014-07-14 17:53:41 +02:00
|
|
|
{
|
|
|
|
name = 'client_dns',
|
|
|
|
src = 'client',
|
|
|
|
dest_port = '53',
|
|
|
|
target = 'REJECT',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:save('firewall')
|
|
|
|
uci:commit('firewall')
|
2014-01-21 03:59:15 +01:00
|
|
|
|
2014-07-14 17:53:41 +02:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
|
|
|
|
uci:set('dhcp', dnsmasq, 'boguspriv', 0)
|
|
|
|
uci:set('dhcp', dnsmasq, 'localise_queries', 0)
|
|
|
|
uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
|
2014-02-21 19:58:38 +01:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:delete('dhcp', 'client')
|
|
|
|
uci:section('dhcp', 'dhcp', 'client',
|
|
|
|
{
|
|
|
|
interface = 'client',
|
|
|
|
ignore = 1,
|
|
|
|
}
|
|
|
|
)
|
2014-02-21 19:58:38 +01:00
|
|
|
|
2014-07-07 22:22:48 +02:00
|
|
|
uci:save('dhcp')
|
|
|
|
uci:commit('dhcp')
|
|
|
|
|
|
|
|
|
|
|
|
sysctl.set('net.ipv6.conf.br-client.forwarding', 0)
|