Hello there! I’m Corels from Emmanuel Corels Creatives, and in today’s guide we’re going to explore advanced logging and auditing techniques in SoftEther VPN. Effective logging is essential for maintaining security and troubleshooting issues in any VPN environment. In this tutorial, I’ll show you how to configure detailed logging, integrate with external syslog servers, and analyze logs using SoftEther’s command-line tools. This knowledge will help you keep a close eye on your VPN activities and quickly diagnose potential issues.
Why Advanced Logging and Auditing?
Logging isn’t just about recording events—it’s a critical tool for:
- Security Monitoring: Identifying unauthorized access attempts or configuration changes.
- Troubleshooting: Pinpointing the cause of connection issues or performance degradations.
- Compliance and Audit: Keeping records for compliance purposes and reviewing historical activity.
- Proactive Maintenance: Catching recurring errors early before they evolve into bigger problems.
Step 1: Accessing and Configuring Logs with vpncmd
-
Launch vpncmd:
Open your terminal and run:sudo /usr/local/softether/vpncmd
At the prompt, select 1 for VPN Server mode and connect locally.
-
Connect to Your Virtual Hub:
For example, if your Virtual Hub is named “MyVPNHub,” type:Hub MyVPNHub
-
Set Log Level:
SoftEther VPN allows you to adjust the logging verbosity. To increase the log detail, enter:LogLevelSet /LEVEL:4
Explanation:
- The higher the level, the more detailed the logs. Level 4 provides ample detail for troubleshooting while still being manageable.
-
View Log Entries:
To review recent events, use:LogPrint
This command displays the latest log messages, which may include authentication events, connection attempts, and error messages.
Step 2: Configuring Logging Options for Better Audit Trails
-
Log to a File:
SoftEther VPN Server can write logs to a local file for persistent storage. While vpncmd doesn’t have a direct “save log” command, you can redirect log output by using your system’s capabilities. For instance, on Linux you can run:sudo journalctl -u softether.service > /var/log/softether.log
Explanation:
- This command collects logs from the SoftEther VPN Server service and saves them to a file for later analysis.
-
Integrate with an External Syslog Server:
For centralized logging across multiple devices, it’s a good idea to forward logs to a syslog server.- On Linux, configure your syslog daemon (like rsyslog) to capture SoftEther logs. For example, add the following to your rsyslog configuration:
if $programname == 'softether' then /var/log/softether.log & stop
- Ensure SoftEther is configured to send its logs to syslog, if supported by your deployment.
- On Linux, configure your syslog daemon (like rsyslog) to capture SoftEther logs. For example, add the following to your rsyslog configuration:
-
Use VPN Server Manager for Log Viewing:
If you prefer a GUI, the SoftEther VPN Server Manager provides a log viewer that displays recent events. This can be especially useful for quickly scanning for errors or unusual activity.
Step 3: Analyzing Logs for Security and Performance
-
Search for Specific Events:
Use the filtering options in vpncmd or your log viewer to search for keywords. For example, to find failed authentication attempts, look for “fail” or “error” in the logs.LogPrint | grep -i "fail"
Note: If you’re using Linux, piping output to grep works in your terminal.
-
Monitor Connection Events:
Reviewing logs can help you see when clients connect or disconnect. Look for entries that include “UserCreate” or “UserList” events, which indicate changes in active sessions. -
Set Up Automated Alerts:
Consider using scripts or your syslog server’s alerting features to notify you when specific conditions are met (e.g., multiple failed logins within a short period). For example, you might create a script that monitors the log file for repeated “authentication failure” entries and sends an email alert. -
Historical Audit:
Keeping a history of log files is useful for audits and troubleshooting recurring issues. Rotate your logs regularly to prevent them from growing too large, and use log analysis tools like Splunk or ELK Stack to visualize trends over time.
Step 4: Creating a Simple Log Analysis Script
Here’s a sample script that you can run periodically to analyze SoftEther VPN logs. This example is for Linux:
#!/bin/bash
# Log Analysis Script for SoftEther VPN
LOGFILE="/var/log/softether.log"
ALERT_EMAIL="admin@yourdomain.com"
THRESHOLD=5
# Count number of failed login attempts in the last hour
FAIL_COUNT=$(grep -i "authentication fail" $LOGFILE | tail -n 100 | wc -l)
if [ "$FAIL_COUNT" -ge "$THRESHOLD" ]; then
echo "Alert: $FAIL_COUNT failed authentication attempts detected in the last hour." | mail -s "SoftEther VPN Alert" $ALERT_EMAIL
fi
Explanation:
- This script checks your log file for “authentication fail” entries.
- If the count exceeds a specified threshold, it sends an alert email.
- Schedule this script with cron to run every hour:
Add the line:crontab -e
0 * * * * /path/to/your/script.sh
Final Thoughts
Advanced logging and audit techniques are essential for maintaining the security and performance of your SoftEther VPN Server. By configuring detailed logging, integrating with external systems, and setting up automated monitoring and alerts, you gain deep insight into your VPN’s operation. This proactive approach helps you quickly identify and resolve issues, ensuring a stable and secure VPN environment.
Take the time to experiment with these tools and scripts, and adjust your settings to suit your environment’s needs. If you have any questions or need further assistance, feel free to reach out. Happy monitoring, and here’s to a well-secured SoftEther VPN Server!
Explained with clarity by
Corels – Admin, Emmanuel Corels Creatives