This script allows you to use a WireGuard VPN server with ConfigServer Security & Firewall (CSF) by setting up the various rules.
-
Copy the script to
/etc/csf/csfpre.sh:wget -O /etc/csf/csfpre.sh https://raw.githubusercontent.com/Scott-Mc/csf-wireguard/refs/heads/main/csfpre.sh
-
Ensure the script is executable:
chmod +x /etc/csf/csfpre.sh
-
Edit /etc/csf/csfpre.sh and configure the script for your WireGuard setup
Ensure you configure the following variables in the script to match your WireGuard and server setup:
- MAIN_INTERFACE: The primary network interface on your server (e.g.,
eth0). - WIREGUARD_INTERFACE: The WireGuard interface (e.g.,
wg0). - WIREGUARD_RANGE: The IP range used by WireGuard clients (This is the Address = line in your /etc/wireguard/wg0.conf).
- WIREGUARD_PORT: The port WireGuard is listening on (This is the ListenPort confgured in /etc/wireguard/wg0.conf).
Example:
MAIN_INTERFACE="eth0" WIREGUARD_INTERFACE="wg0" WIREGUARD_RANGE="10.0.0.1/24" WIREGUARD_PORT="52811"
- MAIN_INTERFACE: The primary network interface on your server (e.g.,
-
Restart CSF to apply changes:
csf -r
This script is licensed under the MIT License. See the LICENSE file for more details.
- Author: Scott Mcintyre (me@scott.cm)
Feel free to open issues or submit pull requests to contribute to this project. Any improvements or suggestions are welcome.