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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 lutil = require 'luci.util'
  7. local gw_sel_class
  8. if site.mesh and site.mesh.batman_adv then
  9. gw_sel_class = site.mesh.batman_adv.gw_sel_class
  10. end
  11. uci:delete('batman-adv', 'bat0')
  12. uci:section('batman-adv', 'mesh', 'bat0',
  13. {
  14. orig_interval = 5000,
  15. gw_mode = 'client',
  16. gw_sel_class = gw_sel_class,
  17. hop_penalty = 15,
  18. multicast_mode = 0,
  19. }
  20. )
  21. uci:save('batman-adv')
  22. if not uci:get('network', 'client', 'ifname') then
  23. uci:add_to_set('network', 'client', 'ifname', 'bat0')
  24. if sysconfig.lan_ifname and not site.mesh_on_lan then
  25. for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
  26. uci:add_to_set('network', 'client', 'ifname', lanif)
  27. end
  28. end
  29. end
  30. uci:set('network', 'client', 'proto', 'dhcpv6')
  31. uci:set('network', 'client', 'reqprefix', 'no')
  32. uci:set('network', 'client', 'igmp_snooping', 0)
  33. uci:set('network', 'client', 'robustness', 3)
  34. uci:set('network', 'client', 'query_interval', 2000)
  35. uci:set('network', 'client', 'query_response_interval', 500)
  36. uci:set('network', 'client', 'peerdns', 1)
  37. uci:set('network', 'client', 'sourcefilter', 0)
  38. uci:delete('network', 'bat0')
  39. uci:section('network', 'interface', 'bat0',
  40. {
  41. ifname = 'bat0',
  42. proto = 'none',
  43. macaddr = sysconfig.primary_mac,
  44. multicast_router = 2,
  45. }
  46. )
  47. uci:save('network')
  48. uci:delete('firewall', 'client')
  49. uci:section('firewall', 'zone', 'client',
  50. {
  51. name = 'client',
  52. network = {'client'},
  53. input = 'ACCEPT',
  54. output = 'ACCEPT',
  55. forward = 'REJECT',
  56. }
  57. )
  58. uci:section('firewall', 'rule', 'client_dns',
  59. {
  60. name = 'client_dns',
  61. src = 'client',
  62. dest_port = '53',
  63. target = 'REJECT',
  64. }
  65. )
  66. uci:save('firewall')
  67. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  68. uci:set('dhcp', dnsmasq, 'boguspriv', 0)
  69. uci:set('dhcp', dnsmasq, 'localise_queries', 0)
  70. uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
  71. uci:delete('dhcp', 'client')
  72. uci:section('dhcp', 'dhcp', 'client',
  73. {
  74. interface = 'client',
  75. ignore = 1,
  76. }
  77. )
  78. uci:save('dhcp')
  79. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)