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

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