1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/usr/bin/lua
- local site = require 'gluon.site_config'
- local uci = require 'luci.model.uci'
- local ip = require 'luci.ip'
- local c = uci.cursor()
- c:delete('network', 'local_node_dev')
- c:section('network', 'device', 'local_node_dev',
- {
- name = 'local-node',
- ifname = 'br-client',
- type = 'macvlan',
- macaddr = site.next_node.mac,
- }
- )
- local ip4, netmask
- if site.next_node.ip4 then
- ip4 = site.next_node.ip4
- netmask = ip.IPv4(site.prefix4):mask():string()
- end
- c:delete('network', 'local_node')
- c:section('network', 'interface', 'local_node',
- {
- ifname = 'local-node',
- proto = 'static',
- ipaddr = ip4,
- netmask = netmask,
- ip6addr = site.next_node.ip6 .. '/128',
- }
- )
- c:delete('network', 'local_node_route6')
- c:section('network', 'route6', 'local_node_route6',
- {
- interface = 'client',
- target = site.prefix6,
- gateway = '::',
- }
- )
- c:save('network')
- c:delete('firewall', 'local_node')
- c:section('firewall', 'zone', 'local_node',
- {
- name = 'local_node',
- network = {'local_node'},
- input = 'ACCEPT',
- output = 'ACCEPT',
- forward = 'REJECT',
- }
- )
- c:save('firewall')
|