310-gluon-mesh-batman-adv-core-mesh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/lua
  2. local sysconfig = require 'gluon.sysconfig'
  3. local sysctl = require 'gluon.sysctl'
  4. local site = require 'gluon.site_config'
  5. local uci = require('luci.model.uci').cursor()
  6. local gw_sel_class
  7. if site.mesh and site.mesh.batman_adv then
  8. gw_sel_class = site.mesh.batman_adv.gw_sel_class
  9. end
  10. uci:delete('batman-adv', 'bat0')
  11. uci:section('batman-adv', 'mesh', 'bat0',
  12. {
  13. orig_interval = 5000,
  14. gw_mode = 'client',
  15. gw_sel_class = gw_sel_class,
  16. hop_penalty = 15,
  17. multicast_mode = 0,
  18. }
  19. )
  20. uci:save('batman-adv')
  21. uci:add_to_set('network', 'client', 'ifname', 'bat0')
  22. uci:set('network', 'client', 'proto', 'dhcpv6')
  23. uci:set('network', 'client', 'reqprefix', 'no')
  24. uci:delete('network', 'client', 'igmp_snooping')
  25. uci:set('network', 'client', 'robustness', 3)
  26. uci:set('network', 'client', 'query_interval', 2000)
  27. uci:set('network', 'client', 'query_response_interval', 500)
  28. uci:set('network', 'client', 'peerdns', 1)
  29. uci:set('network', 'client', 'sourcefilter', 0)
  30. uci:delete('network', 'bat0')
  31. uci:section('network', 'interface', 'bat0',
  32. {
  33. ifname = 'bat0',
  34. proto = 'none',
  35. macaddr = sysconfig.primary_mac,
  36. multicast_router = 2,
  37. learning = 1,
  38. }
  39. )
  40. uci:delete('network', 'client_lan')
  41. uci:save('network')
  42. uci:delete('firewall', 'client')
  43. uci:section('firewall', 'zone', 'client',
  44. {
  45. name = 'client',
  46. network = {'client'},
  47. input = 'ACCEPT',
  48. output = 'ACCEPT',
  49. forward = 'REJECT',
  50. }
  51. )
  52. uci:section('firewall', 'rule', 'client_dns',
  53. {
  54. name = 'client_dns',
  55. src = 'client',
  56. dest_port = '53',
  57. target = 'REJECT',
  58. }
  59. )
  60. uci:save('firewall')
  61. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  62. uci:set('dhcp', dnsmasq, 'boguspriv', 0)
  63. uci:set('dhcp', dnsmasq, 'localise_queries', 0)
  64. uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
  65. uci:delete('dhcp', 'client')
  66. uci:section('dhcp', 'dhcp', 'client',
  67. {
  68. interface = 'client',
  69. ignore = 1,
  70. }
  71. )
  72. uci:save('dhcp')
  73. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)