[root@rhce-ryanrudolf]# rm -rf / 2> /dev/null

things I break/fix for fun and learning

Jun 12, 2019 - 3 minute read - Comments

Hosting My Own KMS Server and Creating BIND DNS Records for Streamlined Windows and Office Activation

DISCLAIMER: The below items are for educational (and entertainment) purposes only.

There are several KMS servers floating in the internet with the sole function of activating copies of Windows and MS Office. Being the curious type, I wanted to know how to implement it in my homelab environment. I was able to find an open-source KMS emulator that runs on multiple platforms (several flavors of Linux, BSD, Solaris, etc etc). So let’s get started!

Preparing the Linux VM

  • Create a CentOS7 virtual machine using minimal ISO. (I’m using my own spacewalk kickstart ISO to perform automated PXE network install. It also automatically registers to my spacewalk server.)

  • Once the VM is created, login as root and change the hostname. For this host, I will use the hostname kms.

    hostnamectl set-hostname kms
  • Change IP address from dynamic to static. For this server, I will use and use my own DNS server

    nmcli con show
    nmcli con mod ens192 ipv4.method manual ipv4.address ipv4.gateway ipv4.dns ipv4.dns-search ryanrudolf.com
    systemctl restart network
  • Since this is managed by my own spacewalk server, we need to import the spacewalk certificates to be able to install packages from the spacewalk server. This saves time and bandwidth as the packages are stored locally on my spacewalk server.

    rpm --import http://spacewalk.ryanrudolf.com/pub/RPM-GPG-KEY-CentOS-7
    rpm --import http://spacewalk.ryanrudolf.com/pub/RPM-GPG-KEY-EPEL-7
  • Do a yum update to install package updates for the server.

Installing the KMS Server

  • The KMS server is available as binaries or source code that needs to be compiled. I prefer the source code, and for this we need to install the git and gcc packages. Git is used to pull / download the source code and gcc is used to compile the source code.

    yum install git gcc
  • Pull / download the KMS server source code -

    git clone https://github.com/Wind4/vlmcsd
  • Compile the source code -

    cd vlmcsd
  • Run the KMS server -

  • Test the KMS server by running the KMS client.

  • If everything is working, it should display like this -

    Connecting to ... successful
    Sending activation request (KMS V6) 1 of 1  -> 06401-00206-568-168948-03-13321-9600.0000-1392019 (3A1C049600B60076)

Creating DNS Records for the KMS Server

  • Login to DNS server and add the A record kms to the forward and reverse zone. This will allow the server to be accessed using server name kms instead of IP address.

    ssh root@sid
    echo "kms IN A" >> /var/named/ryanrudolf.com.zone
    echo "250 IN PTR kms.ryanrudolf.com. >> /var/named/ryanrudolf.com.revzone
    systemctl restart named
  • Still within the DNS server, add the SRV record to the forward zone. This is where the magic happens - KMS clients (Windows / Office) will find the KMS server and activate automatically.

    echo "_vlmcs._tcp.ryanrudolf.com 3600 IN SRV 10 0 1688 kms.ryanrudolf.com" >> /var/named/ryanrudolf.com.zone
    systemctl restart named

And that’s about it! Tested it works on Windows 10, Windows Server 2012, Windows Server 2016 and Office 2016!

Windows Server 2016 Activated using my KMS Server Windows 2016

Windows Server 2012 Activated using my KMS Server Windows 2012

Windows 10 Activated using my KMS Server Windows 10

Office 2016 Activated using my KMS Server Office 2016

Like this page? Share it!