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

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