Guide to Configuring WireGuard on a SoftEther VPN Server
SoftEther is a sophisticated, multi-protocol VPN solution that supports a wide range of VPN protocols, including WireGuard, OpenVPN, L2TP/IPsec, SSTP, and more. In this guide, we focus on configuring the WireGuard protocol on a SoftEther VPN Server using the vpncmd
utility – the only currently supported setup method for WireGuard on SoftEther.
Prerequisites
Before you begin, ensure that:
Step 1: Configuring the UDP Port for WireGuard
Ensure you have administrator privileges for the VPN server before setting up the WireGuard connection. Start by running the vpncmd
utility, selecting option #1 and logging in as Administrator:
./vpncmd
To verify if your SoftEther server is listening on a UDP port, execute the following command:
PortsUDPGet
If no UDP port is active, add one using the command below. You can set any port number, provided it does not conflict with existing ports on your Linux server:
PortsUDPSet 51820
Note: You can specify multiple ports simultaneously by separating them with commas. Ensure that these ports are not blocked by your server’s firewall or iptables.
Step 2: Setting the Default Gateway and Subnet for WireGuard
Because WireGuard doesn’t support DHCP (which relies on broadcast messages that don’t work over a point-to-point VPN tunnel), each peer must have a manually configured (static) IP address to ensure proper encryption and routing. Switch to your virtual hub and configure the default gateway and subnet mask that your WireGuard clients with static IP addresses will use:
Hub myhub
SetStaticNetwork /GATEWAY=192.168.1.1 /SUBNET=255.255.255.0
Replace 192.168.1.1 and 255.255.255.0 with the appropriate gateway IP and subnet mask – the same as your hub’s DHCP server provides to connected clients. Verify that Hub’s static network has been configured correctly by running this command:
OptionsGet myhub
Step 3: Enabling the WireGuard Protocol
Although WireGuard support is typically enabled by default, verify its activation by running the following command:
ProtoOptionsSet wireguard /NAME=enabled /VALUE=true
Step 4: Generating and Assigning User Keys
WireGuard uses X25519 key pairs for secure communication. You can generate these keys using the vpncmd
utility or an external tool. In the example below, keys are generated via vpncmd
.
Exit vpncmd
and relaunch it, then select option #3 to enter Tools mode. Run the following command to generate a key pair:
GenX25519
The tool will generate a pair of keys – a Private Key and a Public Key. Copy and securely store these keys. If you have multiple hubs or users that require a WireGuard connection, generate a separate key pair for each.
After generating the keys, login to vpncmd
as administrator again and assign each user’s Public X25519 key to the appropriate hub:
WgkAdd "WFPFO/s8UXD6HNH+2P2UjfbkUP8BFITa7TXKculvDUk=" /HUB=myhub /USER=myuser
Replace WFPFO/s…ulvDUk=, myhub, and myuser with your actual public key, hub name, and username. Make sure that this user exits on specified hub.
Now, you can verify that the WireGuard keys were added correctly with the following command:
WgkEnum
Step 5: Creating a Sample WireGuard Client Configuration
Below is a sample configuration file. Copy it to a text editor and replace the placeholders with your actual values, which we’ll explain in a moment:
[Interface]
PrivateKey = WFPFO/s8UXD6HNH+2P2UjfbkUP8BFITa7TXKculvDUk=
Address = 192.168.1.15/32
DNS = 9.9.9.9,149.112.112.112
[Peer]
PublicKey = pbnWflgIl4CUqYkgZKrtQg/jMAyytyS/AufEt4OAq3Y=
PresharedKey = s/8eDb4r6BUtAMZEY8a+VC4Qs4HYzUJVqD8YzSNFzuk=
AllowedIPs = 0.0.0.0/0
Endpoint = 150.151.152.153:51820
PersistentKeepalive = 21
[Interface] Section
[Peer] Section
By setting the UDP port, configuring the default gateway and subnet, enabling the WireGuard protocol, generating and assigning keys, and creating a client configuration file, you should now be able to establish a secure connection to your SoftEther virtual hub via WireGuard. Once connected, check if your traffic is routed through the WireGuard tunnel to your SoftEther server.