400-next-node 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site_config'
  3. local uci = require 'luci.model.uci'
  4. local ip = require 'luci.ip'
  5. local c = uci.cursor()
  6. c:delete('network', 'local_node_dev')
  7. c:section('network', 'device', 'local_node_dev',
  8. {
  9. name = 'local-node',
  10. ifname = 'br-client',
  11. type = 'macvlan',
  12. macaddr = site.next_node.mac,
  13. }
  14. )
  15. local ip4, netmask
  16. if site.next_node.ip4 then
  17. ip4 = site.next_node.ip4
  18. netmask = ip.IPv4(site.prefix4):mask():string()
  19. end
  20. c:delete('network', 'local_node')
  21. c:section('network', 'interface', 'local_node',
  22. {
  23. ifname = 'local-node',
  24. proto = 'static',
  25. ipaddr = ip4,
  26. netmask = netmask,
  27. ip6addr = site.next_node.ip6 .. '/128',
  28. }
  29. )
  30. c:delete('network', 'local_node_route6')
  31. c:section('network', 'route6', 'local_node_route6',
  32. {
  33. interface = 'client',
  34. target = site.prefix6,
  35. gateway = '::',
  36. }
  37. )
  38. c:save('network')
  39. c:delete('firewall', 'local_node')
  40. c:section('firewall', 'zone', 'local_node',
  41. {
  42. name = 'local_node',
  43. network = {'local_node'},
  44. input = 'ACCEPT',
  45. output = 'ACCEPT',
  46. forward = 'REJECT',
  47. }
  48. )
  49. c:save('firewall')