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

在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.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服务

  1. 创建配置文件
    编辑启动脚本 /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
    }
    
  2. 设置权限并启用服务

    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 激活
  1. 以管理员身份运行CMD:
    slmgr /skms 192.168.1.1  # 替换为OpenWrt的IP
    slmgr /ato
    slmgr /dlv  # 检查激活状态
    
Office 激活
  1. 进入Office安装目录(如 C:\Program Files\Microsoft Office\Office16):
    cscript ospp.vbs /sethst:192.168.1.1
    cscript 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服务器。此服务仅适用于本地网络,请确保遵守软件许可协议。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值