在OpenWrt上搭建KMS(Key Management Service)服务器,可用于激活Windows和Office。以下是详细步骤:
一、安装KMS服务端(vlmcsd)
SSH登录OpenWrt
使用终端工具连接路由器:
ssh root@192.168.1.1 # 替换为你的路由器IP
更新软件包列表
opkg update
安装vlmcsd
- 方法1:从官方源安装(推荐):opkg install vlmcsd
- 方法2:手动下载安装(适用于官方源无包的情况):# 下载适合你架构的IPK(示例为x86_64)
wget https://github.com/Wind4/vlmcsd/releases/download/svn1113/binaries.tar.gz
tar -xzf binaries.tar.gz
cd binaries/Linux/intel/static
cp vlmcsd-x64-musl-static /usr/bin/vlmcsd
chmod +x /usr/bin/vlmcsd
二、配置KMS服务
创建配置文件
编辑启动脚本 /etc/init.d/vlmcsd:
#!/bin/sh /etc/rc.common
START=99
SERVICE_USE_PID=1
start() {
service_start /usr/bin/vlmcsd -l /var/log/vlmcsd.log -e -v
}
stop() {
service_stop /usr/bin/vlmcsd
}
设置权限并启用服务
chmod +x /etc/init.d/vlmcsd
/etc/init.d/vlmcsd enable
/etc/init.d/vlmcsd start
三、配置防火墙
允许KMS默认端口 1688/TCP:
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-KMS'
uci set firewall.@rule[-1].src='lan'
uci set firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].dest_port='1688'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit firewall
/etc/init.d/firewall restart
四、客户端激活测试
Windows 激活
slmgr /ato
slmgr /dlv # 检查激活状态
Office 激活
cscript ospp.vbs /act
五、验证服务运行
检查服务状态
netstat -tln | grep 1688 # 应看到 0.0.0.0:1688 监听
logread | grep vlmcsd # 查看日志
手动测试激活
vlmcs # 如果安装了客户端
常见问题解决
端口占用
确保无其他程序占用1688端口:
netstat -tlnp | grep 1688
服务无法启动
检查二进制文件权限:
chmod +x /usr/bin/vlmcsd
防火墙拦截
确认防火墙规则已生效:
iptables -L -n | grep 1688
通过以上步骤,你已成功在OpenWrt上搭建KMS服务器。此服务仅适用于本地网络,请确保遵守软件许可协议。
评论前必须登录!
注册