gluon-client-bridge: add default next-node MAC address
The next-node MAC address doesn't need to be unique in different communities, so we can as well add a default value.
This commit is contained in:
parent
f9f68535aa
commit
08e667ba2e
@ -80,9 +80,6 @@
|
|||||||
-- anycast IPs of all nodes
|
-- anycast IPs of all nodes
|
||||||
ip4 = '10.xxx.0.xxx',
|
ip4 = '10.xxx.0.xxx',
|
||||||
ip6 = 'fdxx:xxxx:xxxx::xxxx',
|
ip6 = 'fdxx:xxxx:xxxx::xxxx',
|
||||||
|
|
||||||
-- anycast MAC of all nodes
|
|
||||||
mac = 'xe:xx:xx:xx:xx:xx',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Options specific to routing protocols (optional)
|
-- Options specific to routing protocols (optional)
|
||||||
|
@ -114,7 +114,7 @@ wifi24 \: optional
|
|||||||
interface's ESSID. This is the WiFi the clients connect to.
|
interface's ESSID. This is the WiFi the clients connect to.
|
||||||
|
|
||||||
``mesh`` requires a single parameter, a string, named ``id`` which sets the
|
``mesh`` requires a single parameter, a string, named ``id`` which sets the
|
||||||
mesh id, also visible as an open WiFi in some network managers. Usually you
|
mesh id, also visible as an open WiFi in some network managers. Usually you
|
||||||
don't want users to connect to this mesh-SSID, so use a cryptic id that no
|
don't want users to connect to this mesh-SSID, so use a cryptic id that no
|
||||||
one will accidentally mistake for the client WiFi.
|
one will accidentally mistake for the client WiFi.
|
||||||
|
|
||||||
@ -154,10 +154,14 @@ next_node \: package
|
|||||||
next_node = {
|
next_node = {
|
||||||
ip4 = '10.23.42.1',
|
ip4 = '10.23.42.1',
|
||||||
ip6 = 'fdca:ffee:babe:1::1',
|
ip6 = 'fdca:ffee:babe:1::1',
|
||||||
mac = 'ca:ff:ee:ba:be:00'
|
mac = '16:41:95:40:f7:dc'
|
||||||
}
|
}
|
||||||
|
|
||||||
The IPv4 next-node address is optional.
|
All values of this section are optional. If the IPv4 or IPv6 address is
|
||||||
|
omitted, there will be no IPv4 or IPv6 anycast address. The MAC address
|
||||||
|
defaults to ``16:41:95:40:f7:dc``; this value usually doesn't need to be
|
||||||
|
changed, but it can be adjusted to match existing deployments that use a
|
||||||
|
different value.
|
||||||
|
|
||||||
mesh \: optional
|
mesh \: optional
|
||||||
Options specific to routing protocols.
|
Options specific to routing protocols.
|
||||||
@ -284,7 +288,7 @@ mesh_on_wan \: optional
|
|||||||
mesh_on_lan \: optional
|
mesh_on_lan \: optional
|
||||||
Enables the mesh on the LAN port (``true`` or ``false``).
|
Enables the mesh on the LAN port (``true`` or ``false``).
|
||||||
::
|
::
|
||||||
|
|
||||||
mesh_on_lan = true,
|
mesh_on_lan = true,
|
||||||
|
|
||||||
poe_passthrough \: optional
|
poe_passthrough \: optional
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
|
need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$', false)
|
||||||
|
|
||||||
if need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false) then
|
if need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false) then
|
||||||
need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
|
need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$')
|
||||||
end
|
end
|
||||||
|
|
||||||
need_string_match('next_node.ip6', '^[%x:]+$', false)
|
need_string_match('next_node.ip6', '^[%x:]+$', false)
|
||||||
|
|
||||||
|
|
||||||
for _, config in ipairs({'wifi24', 'wifi5'}) do
|
for _, config in ipairs({'wifi24', 'wifi5'}) do
|
||||||
if need_table(config .. '.ap', nil, false) then
|
if need_table(config .. '.ap', nil, false) then
|
||||||
need_string(config .. '.ap.ssid')
|
need_string(config .. '.ap.ssid')
|
||||||
need_boolean(config .. '.ap.disabled', false)
|
need_boolean(config .. '.ap.disabled', false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
#!/usr/bin/lua
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local client_bridge = require 'gluon.client_bridge'
|
||||||
local site = require 'gluon.site_config'
|
local site = require 'gluon.site_config'
|
||||||
local sysconfig = require 'gluon.sysconfig'
|
local sysconfig = require 'gluon.sysconfig'
|
||||||
|
|
||||||
local uci = require('simple-uci').cursor()
|
local uci = require('simple-uci').cursor()
|
||||||
|
|
||||||
|
|
||||||
|
local next_node = site.next_node or {}
|
||||||
|
|
||||||
|
|
||||||
uci:delete('network', 'local_node_dev')
|
uci:delete('network', 'local_node_dev')
|
||||||
uci:section('network', 'device', 'local_node_dev', {
|
uci:section('network', 'device', 'local_node_dev', {
|
||||||
type = 'veth',
|
type = 'veth',
|
||||||
name = 'local-node',
|
name = 'local-node',
|
||||||
macaddr = site.next_node.mac,
|
macaddr = client_bridge.next_node_macaddr(),
|
||||||
peer_name = 'local-port',
|
peer_name = 'local-port',
|
||||||
peer_macaddr = sysconfig.primary_mac,
|
peer_macaddr = sysconfig.primary_mac,
|
||||||
})
|
})
|
||||||
@ -18,13 +22,13 @@ uci:section('network', 'device', 'local_node_dev', {
|
|||||||
|
|
||||||
local ip4, ip6
|
local ip4, ip6
|
||||||
|
|
||||||
if site.next_node.ip4 then
|
if next_node.ip4 then
|
||||||
local plen = site.prefix4:match('/%d+$')
|
local plen = site.prefix4:match('/%d+$')
|
||||||
ip4 = site.next_node.ip4 .. plen
|
ip4 = next_node.ip4 .. plen
|
||||||
end
|
end
|
||||||
|
|
||||||
if site.next_node.ip6 then
|
if next_node.ip6 then
|
||||||
ip6 = site.next_node.ip6 .. '/128'
|
ip6 = next_node.ip6 .. '/128'
|
||||||
end
|
end
|
||||||
|
|
||||||
uci:delete('network', 'local_node')
|
uci:delete('network', 'local_node')
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
local site = require 'gluon.site_config'
|
||||||
|
|
||||||
|
|
||||||
|
module 'gluon.client_bridge'
|
||||||
|
|
||||||
|
function next_node_macaddr()
|
||||||
|
return (site.next_node or {}).mac or '16:41:95:40:f7:dc'
|
||||||
|
end
|
@ -1,10 +1,13 @@
|
|||||||
|
local client_bridge = require 'gluon.client_bridge'
|
||||||
local site = require 'gluon.site_config'
|
local site = require 'gluon.site_config'
|
||||||
local next_node = site.next_node
|
local next_node = site.next_node or {}
|
||||||
|
|
||||||
rule('FORWARD --logical-out br-client -o bat0 -d ' .. next_node.mac .. ' -j DROP')
|
local macaddr = client_bridge.next_node_macaddr()
|
||||||
rule('OUTPUT --logical-out br-client -o bat0 -d ' .. next_node.mac .. ' -j DROP')
|
|
||||||
rule('FORWARD --logical-out br-client -o bat0 -s ' .. next_node.mac .. ' -j DROP')
|
rule('FORWARD --logical-out br-client -o bat0 -d ' .. macaddr .. ' -j DROP')
|
||||||
rule('OUTPUT --logical-out br-client -o bat0 -s ' .. next_node.mac .. ' -j DROP')
|
rule('OUTPUT --logical-out br-client -o bat0 -d ' .. macaddr .. ' -j DROP')
|
||||||
|
rule('FORWARD --logical-out br-client -o bat0 -s ' .. macaddr .. ' -j DROP')
|
||||||
|
rule('OUTPUT --logical-out br-client -o bat0 -s ' .. macaddr .. ' -j DROP')
|
||||||
|
|
||||||
if next_node.ip4 then
|
if next_node.ip4 then
|
||||||
rule('FORWARD --logical-out br-client -o bat0 -p ARP --arp-ip-src ' .. next_node.ip4 .. ' -j DROP')
|
rule('FORWARD --logical-out br-client -o bat0 -p ARP --arp-ip-src ' .. next_node.ip4 .. ' -j DROP')
|
||||||
|
Loading…
Reference in New Issue
Block a user