110-network 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/lua
  2. local uci = require('simple-uci').cursor()
  3. local sysctl = require 'gluon.sysctl'
  4. local sysconfig = require 'gluon.sysconfig'
  5. uci:section('network', 'interface', 'wan',
  6. {
  7. ifname = sysconfig.wan_ifname,
  8. type = 'bridge',
  9. multicast_querier = false,
  10. peerdns = false,
  11. auto = true,
  12. }
  13. )
  14. uci:delete('network', 'wan', 'igmp_snooping')
  15. if not uci:get('network', 'wan', 'proto') then
  16. uci:set('network', 'wan', 'proto', 'dhcp')
  17. end
  18. uci:section('network', 'interface', 'wan6',
  19. {
  20. ifname = 'br-wan',
  21. peerdns = false,
  22. ip6table = 1,
  23. sourcefilter = false,
  24. }
  25. )
  26. if not uci:get('network', 'wan6', 'proto') then
  27. uci:set('network', 'wan6', 'proto', 'dhcpv6')
  28. end
  29. uci:section('network', 'rule6', 'wan6_lookup',
  30. {
  31. mark = '0x01/0x01',
  32. lookup = 1,
  33. }
  34. )
  35. uci:section('network', 'route6', 'wan6_unreachable',
  36. {
  37. type = 'unreachable',
  38. interface = 'loopback',
  39. target = '::/0',
  40. gateway = '::',
  41. table = 1,
  42. metric = 65535,
  43. }
  44. )
  45. uci:save('network')
  46. uci:section('firewall', 'rule', 'wan_igmp',
  47. {
  48. name = 'Allow-IGMP',
  49. src = 'wan',
  50. proto = 'igmp',
  51. family = 'ipv4',
  52. target = 'ACCEPT',
  53. }
  54. )
  55. uci:section('firewall', 'rule', 'wan_mld',
  56. {
  57. name = 'Allow-MLD',
  58. src = 'wan',
  59. proto = 'icmp',
  60. src_ip = 'fe80::/10',
  61. icmp_type = { '130/0', '131/0', '132/0', '143/0', },
  62. family = 'ipv6',
  63. target = 'ACCEPT',
  64. }
  65. )
  66. uci:save('firewall')
  67. sysctl.set('net.ipv6.conf.all.accept_ra', 0)
  68. sysctl.set('net.ipv6.conf.default.accept_ra', 0)