300-gluon-client-bridge-network 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 uci:get_bool('network', 'mesh_lan', 'disabled') 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. -- TODO: remove this line and the next in 2019. Firewall zones have been renamed in 2017.
  33. uci:delete('firewall', 'client')
  34. uci:section('firewall', 'zone', 'drop', {
  35. name = 'drop',
  36. network = {'client'},
  37. input = 'DROP',
  38. output = 'DROP',
  39. forward = 'DROP',
  40. })
  41. local networks = uci:get_list('firewall', 'local_client', 'network')
  42. util.add_to_set(networks, 'local_node')
  43. uci:set_list('firewall', 'local_client', 'network', networks)
  44. local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
  45. uci:set('dhcp', dnsmasq, 'boguspriv', false)
  46. uci:set('dhcp', dnsmasq, 'localise_queries', false)
  47. uci:set('dhcp', dnsmasq, 'rebind_protection', false)
  48. -- TODO: remove this line and the next two in 2019 the zones were removed in 2017
  49. uci:delete('dhcp', 'client')
  50. uci:delete('firewall', 'local_node')
  51. uci:section('dhcp', 'dhcp', 'local_client', {
  52. interface = 'client',
  53. ignore = true,
  54. })
  55. uci:save('dhcp')
  56. uci:save('firewall')
  57. sysctl.set('net.ipv6.conf.br-client.forwarding', 0)