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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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', 'peerdns', 1)
  34. uci:set('network', 'client', 'sourcefilter', 0)
  35. uci:delete('network', 'bat0')
  36. uci:section('network', 'interface', 'bat0',
  37. {
  38. ifname = 'bat0',
  39. proto = 'none',
  40. macaddr = sysconfig.primary_mac,
  41. }
  42. )
  43. uci:save('network')
  44. uci:delete('firewall', 'client')
  45. uci:section('firewall', 'zone', 'client',
  46. {
  47. name = 'client',
  48. network = {'client'},
  49. input = 'ACCEPT',
  50. output = 'ACCEPT',
  51. forward = 'REJECT',
  52. }
  53. )
  54. uci:section('firewall', 'rule', 'client_dns',
  55. {
  56. name = 'client_dns',
  57. src = 'client',
  58. dest_port = '53',
  59. target = 'REJECT',
  60. }
  61. )
  62. uci:save('firewall')
  63. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  64. uci:set('dhcp', dnsmasq, 'boguspriv', 0)
  65. uci:set('dhcp', dnsmasq, 'localise_queries', 0)
  66. uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
  67. uci:delete('dhcp', 'client')
  68. uci:section('dhcp', 'dhcp', 'client',
  69. {
  70. interface = 'client',
  71. ignore = 1,
  72. }
  73. )
  74. uci:save('dhcp')
  75. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)