1. hostname Please change from default Raspberrypi to test.com
sudo nano /etc/hostname
Please change the raspberrypi in the file to test.com
2. Change the IP address of the Raspberry Pi to static, in this case 172.16.0.68, the gateway exits to 172.16.0.1
sudo nano /etc/dhcpcd.conf
At the bottom of the document, add the following settings:
interface eth0static ip_address=172.16.0.68/24static routers=172.16.0.1static domain_name_servers=22.214.171.124 126.96.36.199
3. Resolve the host itself to 172.16.0.68
sudo nano /etc/hosts
Comment out the record about Raspberrypi and add the following line:
4. Restart Pi
5. In this case, upload the relevant file using the Pscp.exe provided by putty in the Windows system.
First, establish a KMS server
There are a number of ways to build a KMS server on Raspberry Pi 3, and here is a relatively simple and complex one.
Please choose one of them in (i) and (b)!
(a) Use a KMS server file that has been edited.
The file was written by the Hotbird64 God.
To download, you need to register.
After downloading the unpacked files, we need the files as:
Rename the file to: vlmcsdpi
1. Create a new KMS folder
2. Uploading KMS files
Under Win, start cmd or PowerShell, enter the Pscp.exe folder, I will pscp.exe and vlmcsdpi are placed under the E:\putty.
cd e:\puttypscp e:\putty\vlmcsdpi [email protected]:/home/pi/kms/
After entering the pi password, the upload is successful.
3. Give execution permission
chmod 777 /home/pi/kms/vlmcsdpi
4. Set boot from Start
sudo nano /etc/rc.local
Join before exit 0:
/home/pi/kms/vlmcsdpi -l /var/log/vlmcsd.log > /dev/null 2>&1
5. Start the service:
/home/pi/kms/vlmcsdpi -l /var/log/vlmcsd.log
The log file is:/var/log/vlmcsd.log
6, Stop the service:
Find the process number and kill it.
sudo ps -ef | grep vlmcsdpisudo kill -s 9 进程号
This method is built quickly and easy to upgrade. If the HOTBIRD64 the new version, upgrade as long as the new version of the file can be replaced.
(ii) Use of py-kms to build a KMS server
1. Install git
sudo apt-get install git
2. Download the py-kms in the Pi home directory:
git clone https://github.com/myanaloglife/py-kms
Because the pi comes with Python, the initial test can be done after the download:
cd py-kms python server.py
The prompt for success. Press CTRL + C to exit.
3. Use supervisor to ensure long-term operation of KMS services:
Now put py-kms into/usr/local/:
sudo cp -r py-kms /usr/local/
Write a configuration file
mv /etc/supervisord.conf /etc/supervisord.conf.baksudo nano /etc/supervisord.conf
The contents are:
file = /var/run/supervisord.sock
chmod = 0777
chown = root: root
port = *: 9001
username = pi
password = yourpassword
; Must match the setting in ‘unix_http_server’
serverurl = unix: ///var/run/supervisord.sock
logfile = / var / log / supervisord.log; (main log file; default $ CWD / supervisord.log)
logfile_maxbytes = 50MB; (max main logfile bytes b4 rotation; default 50MB)
logfile_backups = 10; (num of main logfile rotation backups; default 10)
loglevel = info; (log level; default info; others: debug, warn, trace)
pidfile = / var / run / supervisord.pid; (supervisord pidfile; default supervisord.pid)
nodaemon = true; (start in foreground if true; default false)
minfds = 1024; (min. avail startup file descriptors; default 1024)
minprocs = 200; (min. avail process descriptors; default 200)
user = root; (default is current user, required if root)
childlogdir = / var / log /; (‘AUTO’ child log dir, default $ TEMP)
supervisor.rpcinterface_factory = supervisor.rpcinterface: make_main_rpcinterface
command = python /usr/local/py-kms/server.py
autorestart = true
user = root
After writing the configuration file, execute:
sudo chmod 777 /var/run
sudo chmod 777 /var/log
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
4. Enable the Supervisor to boot:
sudo nano /etc/rc.local
Join before exit 0:
After restarting the PI, see if the process starts normally:
Under normal circumstances, the server.py should be running.
Quit with quit.
5. Test the KMS server:
cd /usr/local/py-kmspython client.py -v 172.16.0.68
The test results are:
Connecting to 172.16.0.68 on port 1688...
Sending RPC bind request...
RPC bind acknowledged.
is a success.
Second, make the machine in the LAN can activate itself
Before you begin this step, make sure that all other DHCP servers on the LAN are down!
1. Create a/etc/resolv.dnsmasq.conf file
sudo cp /etc/resolv.conf /etc/resolv.dnsmasq.confsudo nano /etc/resolv.dnsmasq.conf
To delete the original contents of the file, create the following:
nameserver 188.8.131.52nameserver 184.108.40.206
2. Installing the software for testing DNS
sudo apt-get install dnsutils
3. Install a lightweight DNS forwarding server, DHCP server
sudo apt-get install dnsmasq
4. Configure DNSMASQ:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.baksudo nano /etc/dnsmasq.conf
The configuration content is as follows:
#Specify the upstream server address, determined by the contents of the /etc/resolv.dnsmasq.conf file
resolv-file = / etc / resolv.dnsmasq.conf
# Strictly follow the order in resolv.dnsmasq.conf
listen-address = 172.16.0.68,127.0.0.1
#Address pool settings
dhcp-range = 172.16.0.100,172.16.0.200,255.255.255.0,6h
#Set LAN suffix name, important, please be sure to set
domain = test.com
#Designated gateway (route exit)
dhcp-option = 3,172.16.0.1
# dhcp-option = option: router, 172.16.0.1
#Specify the DNS assigned to the client when the address is distributed, in addition to the local dns server address, other dns addresses are added for insurance purposes
dhcp-option = option: dns-server, 172.16.0.68,220.127.116.11
# server = 18.104.22.168
#Usually used to prohibit access to a domain name that does not exist, to prevent it from jumping to the operator's advertising site.
bogus-nxdomain = 22.214.171.124
#Set kms server response
srv-host = _vlmcs._tcp, test.com, 1688,0,100
#Enable log recording, specify the log file path and file name
log-facility = / var / log / dnsmasq.log
To restart the DNS service:
sudo service dnsmasq restart
5. The test command is as follows: (Test in Windows system, be sure to ensure that other DHCP servers on the network have been shut down and the Windows system has auto-get address enabled)
Under Win, start Cmd or powershell
nslookup -type=srv _vlmcs._tcp
nslookup -q=srv _vlmcs._tcp.test.com
The following 2 commands must all be fed back with the same result:
_vlmcs._tcp.test.com SRV service location:
priority = 0
weight = 100
port = 1688
svr hostname = test.com
test.com internet address = 172.16.0.68
KMS auto-activation on Raspberry Pi 3 (raspberrypi 3B)