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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/lua
  2. local sysconfig = require 'gluon.sysconfig'
  3. local sysctl = require 'gluon.sysctl'
  4. local uci = require('luci.model.uci').cursor()
  5. uci:delete('batman-adv', 'bat0')
  6. uci:section('batman-adv', 'mesh', 'bat0',
  7. {
  8. orig_interval = 5000,
  9. gw_mode = 'client',
  10. multicast_mode = 0,
  11. }
  12. )
  13. uci:save('batman-adv')
  14. uci:commit('batman-adv')
  15. if not uci:get('network', 'client') then
  16. local ifname
  17. if sysconfig.lan_ifname then
  18. ifname = sysconfig.lan_ifname .. ' bat0'
  19. else
  20. ifname = 'bat0'
  21. end
  22. uci:section('network', 'interface', 'client',
  23. {
  24. ifname = ifname,
  25. type = 'bridge',
  26. proto = 'dhcpv6',
  27. reqprefix = 'no',
  28. }
  29. )
  30. end
  31. uci:set('network', 'client', 'igmp_snooping', 0)
  32. uci:set('network', 'client', 'macaddr', sysconfig.primary_mac)
  33. uci:set('network', 'client', 'peerdns', 1)
  34. uci:delete('network', 'bat0')
  35. uci:section('network', 'interface', 'bat0',
  36. {
  37. ifname = 'bat0',
  38. proto = 'none',
  39. macaddr = sysconfig.primary_mac,
  40. }
  41. )
  42. uci:save('network')
  43. uci:commit('network')
  44. uci:delete('firewall', 'client')
  45. uci:section('firewall', 'zone', 'client',
  46. {
  47. name = 'client',
  48. network = {'client'},
  49. input = 'ACCEPT',
  50. output = 'ACCEPT',
  51. forward = 'REJECT',
  52. }
  53. )
  54. uci:section('firewall', 'rule', 'client_dns',
  55. {
  56. name = 'client_dns',
  57. src = 'client',
  58. dest_port = '53',
  59. target = 'REJECT',
  60. }
  61. )
  62. uci:save('firewall')
  63. uci:commit('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. uci:commit('dhcp')
  77. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)