110-network 1.4 KB

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