300-gluon-client-bridge-network 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. })
  29. uci:save('network')
  30. uci:delete('firewall', 'client')
  31. uci:section('firewall', 'zone', 'client', {
  32. name = 'client',
  33. network = {'client'},
  34. input = 'DROP',
  35. output = 'DROP',
  36. forward = 'DROP',
  37. })
  38. uci:save('firewall')
  39. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  40. uci:set('dhcp', dnsmasq, 'boguspriv', false)
  41. uci:set('dhcp', dnsmasq, 'localise_queries', false)
  42. uci:set('dhcp', dnsmasq, 'rebind_protection', false)
  43. uci:delete('dhcp', 'client')
  44. uci:section('dhcp', 'dhcp', 'client', {
  45. interface = 'client',
  46. ignore = true,
  47. })
  48. uci:save('dhcp')
  49. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)