90_wg-firewall 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. uci set firewall.wg_allow="rule"
  3. uci set firewall.wg_allow.src="*"
  4. uci set firewall.wg_allow.target="ACCEPT"
  5. uci set firewall.wg_allow.proto="udp"
  6. uci set firewall.wg_allow.dest_port="51800"
  7. uci set firewall.wg_allow.name="Allow-Wireguard-Inbound"
  8. # Add the firewall zone
  9. uci add firewall zone
  10. uci set firewall.@zone[-1].name='wg'
  11. uci set firewall.@zone[-1].input='ACCEPT'
  12. uci set firewall.@zone[-1].forward='ACCEPT'
  13. uci set firewall.@zone[-1].output='ACCEPT'
  14. uci set firewall.@zone[-1].masq='1'
  15. # Add the WG interface to it
  16. uci set firewall.@zone[-1].network='wg0'
  17. # Forward WAN and LAN traffic to/from it
  18. uci add firewall forwarding
  19. uci set firewall.@forwarding[-1].src='wg'
  20. uci set firewall.@forwarding[-1].dest='wan'
  21. uci add firewall forwarding
  22. uci set firewall.@forwarding[-1].src='wg'
  23. uci set firewall.@forwarding[-1].dest='lan'
  24. uci add firewall forwarding
  25. uci set firewall.@forwarding[-1].src='lan'
  26. uci set firewall.@forwarding[-1].dest='wg'
  27. uci add firewall forwarding
  28. uci set firewall.@forwarding[-1].src='wan'
  29. uci set firewall.@forwarding[-1].dest='wg'
  30. uci commit firewall
  31. /etc/init.d/firewall restart