1. 下载解压 & 解除区域限制
SoftEtherVPN 源码中的 src/Cedar/Server.c 文件定义了地区限制功能,如果运行区域是 “JP” 或 “CN”,则会禁用一些企业功能,如 RADIUS,RSA 证书,源IP控制和精细记录等。
修改方法:
打开 SoftEtherVPN/src/Cedar/Server.c ,找到如下函数:
bool SiIsEnterpriseFunctionsRestrictedOnOpenSource(CEDAR *c)
{
return false; // 始终不限制企业功能
}
将其修改为直接返回 false,即可解除限制。
2. 编译环境 & 构建
安装编译所需依赖:
sudo yum -y groupinstall "Development Tools"
sudo yum -y install cmake ncurses-devel openssl-devel readline-devel zlib-devel
进入目录:
cd /www/wwwroot/vpnserver
编译:
./.install.sh # 或者 make
编译完成后会得到:
3. 启动 VPN Server
./vpnserver start
./vpncmd
初始化密码:
serverpasswordset
4. 搭建到 /usr/local
sudo mkdir -p /usr/local/vpnserver
sudo cp hamcore.se2 /usr/local/vpnserver/
sudo cp vpncmd /usr/local/vpnserver/
sudo cp vpnserver /usr/local/vpnserver/
5. 添加 systemd 服务
创建文件 /lib/systemd/system/vpnserver.service:
[Unit]
Description=SoftEther Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/vpnserver/vpnserver start
ExecStop=/usr/local/vpnserver/vpnserver stop
[Install]
WantedBy=multi-user.target
启用开机自启:
sudo systemctl enable vpnserver
停用开机自启:
sudo systemctl disable vpnserver
6. 日常管理命令
# 简单命令
sudo /usr/local/vpnserver/vpnserver start
sudo /usr/local/vpnserver/vpnserver stop
# systemd 方式
sudo systemctl start vpnserver
sudo systemctl stop vpnserver
sudo systemctl status vpnserver
7. VPN Client 安装 & 开机自启
创建 /usr/lib/systemd/system/vpnclient.service:
[Unit]
Description=SoftEther VPN Client
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/vpnclient/vpnclient start
ExecStop=/usr/local/vpnclient/vpnclient stop
RestartSec=3
[Install]
WantedBy=multi-user.target
将文件复制到 systemd:
sudo cp /vpnclient.service /lib/systemd/system/vpnclient.service
启用开机自启:
sudo systemctl enable vpnclient
停用开机自启:
sudo systemctl disable vpnclient
手动启动/停止:
sudo systemctl start vpnclient
sudo systemctl stop vpnclient
附录: 编程模板
int i;
for(i=0;i<10;i++)
{
// 遍历
}