110-network 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. reqprefix = 'no',
  22. })
  23. if not uci:get('network', 'wan6', 'proto') then
  24. uci:set('network', 'wan6', 'proto', 'dhcpv6')
  25. end
  26. uci:section('network', 'rule6', 'wan6_lookup', {
  27. mark = '0x01/0x01',
  28. lookup = 1,
  29. })
  30. uci:section('network', 'route6', 'wan6_unreachable', {
  31. type = 'unreachable',
  32. interface = 'loopback',
  33. target = '::/0',
  34. gateway = '::',
  35. table = 1,
  36. metric = 65535,
  37. })
  38. uci:save('network')
  39. uci:section('firewall', 'rule', 'wan_igmp', {
  40. name = 'Allow-IGMP',
  41. src = 'wan',
  42. proto = 'igmp',
  43. family = 'ipv4',
  44. target = 'ACCEPT',
  45. })
  46. uci:section('firewall', 'rule', 'wan_mld', {
  47. name = 'Allow-MLD',
  48. src = 'wan',
  49. proto = 'icmp',
  50. src_ip = 'fe80::/10',
  51. icmp_type = { '130/0', '131/0', '132/0', '143/0', },
  52. family = 'ipv6',
  53. target = 'ACCEPT',
  54. })
  55. uci:save('firewall')
  56. sysctl.set('net.ipv6.conf.all.accept_ra', 0)
  57. sysctl.set('net.ipv6.conf.default.accept_ra', 0)