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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. learning = 0,
  46. }
  47. )
  48. uci:delete('network', 'client_lan')
  49. if sysconfig.lan_ifname then
  50. uci:section('network', 'interface', 'client_lan',
  51. {
  52. unicast_flood = 0,
  53. }
  54. )
  55. uci:set('network', 'client_lan', 'ifname', sysconfig.lan_ifname)
  56. end
  57. uci:save('network')
  58. uci:delete('firewall', 'client')
  59. uci:section('firewall', 'zone', 'client',
  60. {
  61. name = 'client',
  62. network = {'client'},
  63. input = 'ACCEPT',
  64. output = 'ACCEPT',
  65. forward = 'REJECT',
  66. }
  67. )
  68. uci:section('firewall', 'rule', 'client_dns',
  69. {
  70. name = 'client_dns',
  71. src = 'client',
  72. dest_port = '53',
  73. target = 'REJECT',
  74. }
  75. )
  76. uci:save('firewall')
  77. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  78. uci:set('dhcp', dnsmasq, 'boguspriv', 0)
  79. uci:set('dhcp', dnsmasq, 'localise_queries', 0)
  80. uci:set('dhcp', dnsmasq, 'rebind_protection', 0)
  81. uci:delete('dhcp', 'client')
  82. uci:section('dhcp', 'dhcp', 'client',
  83. {
  84. interface = 'client',
  85. ignore = 1,
  86. }
  87. )
  88. uci:save('dhcp')
  89. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)