300-gluon-client-bridge-network 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/lua
  2. local sysconfig = require 'gluon.sysconfig'
  3. local sysctl = require 'gluon.sysctl'
  4. local util = require 'gluon.util'
  5. local uci = require('simple-uci').cursor()
  6. local interfaces = uci:get('network', 'client', 'ifname') or {}
  7. if type(interfaces) == 'string' then
  8. local ifname = interfaces
  9. interfaces = {}
  10. for iface in ifname:gmatch('%S+') do
  11. util.add_to_set(interfaces, iface)
  12. end
  13. end
  14. if sysconfig.lan_ifname and not ifname and not uci:get_bool('network', 'mesh_lan', 'auto') then
  15. for lanif in sysconfig.lan_ifname:gmatch('%S+') do
  16. util.add_to_set(interfaces, lanif)
  17. end
  18. end
  19. util.add_to_set(interfaces, 'local-port')
  20. uci:delete('network', 'client')
  21. uci:section('network', 'interface', 'client', {
  22. type = 'bridge',
  23. ifname = interfaces,
  24. proto = 'none',
  25. auto = true,
  26. ipv6 = false,
  27. macaddr = sysconfig.primary_mac,
  28. igmp_snooping = true,
  29. multicast_querier = true,
  30. })
  31. uci:save('network')
  32. uci:delete('firewall', 'client')
  33. uci:section('firewall', 'zone', 'client', {
  34. name = 'client',
  35. network = {'client'},
  36. input = 'DROP',
  37. output = 'DROP',
  38. forward = 'DROP',
  39. })
  40. uci:save('firewall')
  41. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  42. uci:set('dhcp', dnsmasq, 'boguspriv', false)
  43. uci:set('dhcp', dnsmasq, 'localise_queries', false)
  44. uci:set('dhcp', dnsmasq, 'rebind_protection', false)
  45. uci:delete('dhcp', 'client')
  46. uci:section('dhcp', 'dhcp', 'client', {
  47. interface = 'client',
  48. ignore = true,
  49. })
  50. uci:save('dhcp')
  51. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)