400-next-node 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 prefix4 = ip.IPv4(site.prefix4)
  16. c:delete('network', 'local_node')
  17. c:section('network', 'interface', 'local_node',
  18. {
  19. ifname = 'local-node',
  20. proto = 'static',
  21. ipaddr = site.next_node.ip4,
  22. netmask = prefix4:mask():string(),
  23. ip6addr = site.next_node.ip6 .. '/128',
  24. }
  25. )
  26. c:delete('network', 'local_node_route6')
  27. c:section('network', 'route6', 'local_node_route6',
  28. {
  29. interface = 'client',
  30. target = site.prefix6,
  31. gateway = '::',
  32. }
  33. )
  34. c:save('network')
  35. c:commit('network')
  36. c:delete('firewall', 'local_node')
  37. c:section('firewall', 'zone', 'local_node',
  38. {
  39. name = 'local_node',
  40. network = {'local_node'},
  41. input = 'ACCEPT',
  42. output = 'ACCEPT',
  43. forward = 'REJECT',
  44. }
  45. )
  46. c:save('firewall')
  47. c:commit('firewall')