> 技术文档 > 在OpenWrt上搭建KMS(Key Management Service)服务器_openwrt kms

在OpenWrt上搭建KMS(Key Management Service)服务器_openwrt kms

在OpenWrt上搭建KMS(Key Management Service)服务器,可用于激活Windows和Office。以下是详细步骤:


一、安装KMS服务端(vlmcsd)

  1. SSH登录OpenWrt
    使用终端工具连接路由器:

    ssh root@192.168.1.1 # 替换为你的路由器IP
  2. 更新软件包列表

    opkg update
  3. 安装vlmcsd

    • 方法1:从官方源安装(推荐):
      opkg install vlmcsd
    • 方法2:手动下载安装(适用于官方源无包的情况):
      # 下载适合你架构的IPK(示例为x86_64)wget https://github.com/Wind4/vlmcsd/releases/download/svn1113/binaries.tar.gztar -xzf binaries.tar.gzcd binaries/Linux/intel/staticcp vlmcsd-x64-musl-static /usr/bin/vlmcsdchmod +x /usr/bin/vlmcsd

二、配置KMS服务

  1. 创建配置文件
    编辑启动脚本 /etc/init.d/vlmcsd

    #!/bin/sh /etc/rc.commonSTART=99SERVICE_USE_PID=1start() { service_start /usr/bin/vlmcsd -l /var/log/vlmcsd.log -e -v}stop() { service_stop /usr/bin/vlmcsd}
  2. 设置权限并启用服务

    chmod +x /etc/init.d/vlmcsd/etc/init.d/vlmcsd enable/etc/init.d/vlmcsd start

三、配置防火墙

允许KMS默认端口 1688/TCP

uci add firewall ruleuci 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 激活
  1. 以管理员身份运行CMD:
    slmgr /skms 192.168.1.1 # 替换为OpenWrt的IPslmgr /atoslmgr /dlv # 检查激活状态
Office 激活
  1. 进入Office安装目录(如 C:\\Program Files\\Microsoft Office\\Office16):
    cscript ospp.vbs /sethst:192.168.1.1cscript ospp.vbs /act

五、验证服务运行

  1. 检查服务状态

    netstat -tln | grep 1688 # 应看到 0.0.0.0:1688 监听logread | grep vlmcsd # 查看日志
  2. 手动测试激活

    vlmcs # 如果安装了客户端

常见问题解决

  1. 端口占用
    确保无其他程序占用1688端口:

    netstat -tlnp | grep 1688
  2. 服务无法启动
    检查二进制文件权限:

    chmod +x /usr/bin/vlmcsd
  3. 防火墙拦截
    确认防火墙规则已生效:

    iptables -L -n | grep 1688

通过以上步骤,你已成功在OpenWrt上搭建KMS服务器。此服务仅适用于本地网络,请确保遵守软件许可协议。