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

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