2017-02-10 07:54:48 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
2017-02-10 08:32:39 +00:00
|
|
|
local site = require 'gluon.site_config'
|
2017-02-10 07:54:48 +00:00
|
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
|
|
|
|
|
|
local uci = require('simple-uci').cursor()
|
|
|
|
|
|
|
|
|
|
|
|
uci:delete('network', 'local_node_dev')
|
|
|
|
uci:section('network', 'device', 'local_node_dev', {
|
2017-02-10 08:44:23 +00:00
|
|
|
type = 'veth',
|
2017-02-10 07:54:48 +00:00
|
|
|
name = 'local-node',
|
2017-02-10 08:32:39 +00:00
|
|
|
macaddr = site.next_node.mac,
|
2017-02-10 08:44:23 +00:00
|
|
|
peer_name = 'local-port',
|
|
|
|
peer_macaddr = sysconfig.primary_mac,
|
2017-02-10 07:54:48 +00:00
|
|
|
})
|
|
|
|
|
2017-02-10 08:32:39 +00:00
|
|
|
|
|
|
|
local ip4, ip6
|
|
|
|
|
|
|
|
if site.next_node.ip4 then
|
|
|
|
local plen = site.prefix4:match('/%d+$')
|
|
|
|
ip4 = site.next_node.ip4 .. plen
|
|
|
|
end
|
|
|
|
|
|
|
|
if site.next_node.ip6 then
|
|
|
|
ip6 = site.next_node.ip6 .. '/128'
|
|
|
|
end
|
|
|
|
|
2017-02-10 07:54:48 +00:00
|
|
|
uci:delete('network', 'local_node')
|
|
|
|
uci:section('network', 'interface', 'local_node', {
|
|
|
|
ifname = 'local-node',
|
2017-02-10 08:32:39 +00:00
|
|
|
proto = 'static',
|
|
|
|
ipaddr = ip4,
|
|
|
|
ip6addr = ip6,
|
2017-02-10 07:54:48 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
uci:save('network')
|
|
|
|
|
|
|
|
|
|
|
|
uci:delete('dhcp', 'local_node')
|
|
|
|
uci:section('dhcp', 'dhcp', 'local_node', {
|
|
|
|
interface = 'local_node',
|
|
|
|
ignore = true,
|
|
|
|
})
|
|
|
|
|
|
|
|
uci:save('dhcp')
|