110-network 1.6 KB

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