gluon/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network
Matthias Schiffer c779d12369
treewide: use interface roles as basis for network configuration
With the new role-based interface configuration, it would be better to
rename the wan/wan6 interfaces to uplink/uplink6, but that would cause
unnecessary churn for the firewall configuration, so it is left for a
later update.

As all interfaces with the 'uplink' role are in the br-wan bridge, it is
not possible to assign these to the 'mesh' role independently - instead,
br-wan is added as a mesh interface as soon as a single interface has
both the 'uplink' and 'mesh' roles. The UCI section for this
configuration is now called 'mesh_uplink' instead of 'mesh_wan'.

For all interfaces that have the 'mesh', but not the 'uplink' role a
second configuration 'mesh_other' is created. If there is more than one
such interface, all these interfaces are bridged as well (creating a
bridge 'br-mesh_other'). This replaces the 'mesh_lan' section with its
optional 'br-mesh_lan' bridge, but can also include interfaces that were
not considered "LAN" when interfaces roles are modified (via site.conf
or manually).
2022-02-22 18:52:15 +01:00

51 lines
1.1 KiB
Lua
Executable File

#!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig'
local util = require 'gluon.util'
local uci = require('simple-uci').cursor()
local interfaces = util.get_role_interfaces(uci, 'client', true)
util.add_to_set(interfaces, 'local-port')
uci:section('network', 'interface', 'client', {
type = 'bridge',
ifname = interfaces,
proto = 'none',
auto = true,
ipv6 = false,
macaddr = sysconfig.primary_mac,
igmp_snooping = true,
multicast_querier = true,
ra_holdoff = 30,
})
uci:save('network')
uci:section('firewall', 'zone', 'drop', {
name = 'drop',
network = {'client'},
input = 'DROP',
output = 'DROP',
forward = 'DROP',
})
local networks = uci:get_list('firewall', 'loc_client', 'network')
util.add_to_set(networks, 'local_node')
uci:set_list('firewall', 'loc_client', 'network', networks)
local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
uci:set('dhcp', dnsmasq, 'boguspriv', false)
uci:set('dhcp', dnsmasq, 'localise_queries', false)
uci:set('dhcp', dnsmasq, 'rebind_protection', false)
uci:section('dhcp', 'dhcp', 'local_client', {
interface = 'client',
ignore = true,
})
uci:save('dhcp')
uci:save('firewall')