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 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:commit('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. uci:add_to_set('network', 'client', 'ifname', sysconfig.lan_ifname)
  26. end
  27. end
  28. uci:set('network', 'client', 'proto', 'dhcpv6')
  29. uci:set('network', 'client', 'reqprefix', 'no')
  30. uci:set('network', 'client', 'igmp_snooping', 0)
  31. uci:set('network', 'client', 'peerdns', 1)
  32. uci:set('network', 'client', 'sourcefilter', 0)
  33. uci:delete('network', 'bat0')
  34. uci:section('network', 'interface', 'bat0',
  35. {
  36. ifname = 'bat0',
  37. proto = 'none',
  38. macaddr = sysconfig.primary_mac,
  39. }
  40. )
  41. uci:save('network')
  42. uci:commit('network')
  43. uci:delete('firewall', 'client')
  44. uci:section('firewall', 'zone', 'client',
  45. {
  46. name = 'client',
  47. network = {'client'},
  48. input = 'ACCEPT',
  49. output = 'ACCEPT',
  50. forward = 'REJECT',
  51. }
  52. )
  53. uci:section('firewall', 'rule', 'client_dns',
  54. {
  55. name = 'client_dns',
  56. src = 'client',
  57. dest_port = '53',
  58. target = 'REJECT',
  59. }
  60. )
  61. uci:save('firewall')
  62. uci:commit('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. uci:commit('dhcp')
  76. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)