RustDesk is a remote desktop software, the open source TeamViewer / AnyDesk alternative. You have full control of your data, with no concerns about security since it only sends data to a server that you setup. You can use a public rendezvous/relay server or self-host one. In this step by step guide I will show you how to install RustDesk on your Synology NAS using Docker and DSM 7.2 I've based a significant amount of this guide on https://drfrankenstein.co.uk guides. First, Follow the following 4 guides: Step 0: Docker, Memory Recommendations and Limitations Step 1: Directory Setup Guide Step 2: Setting up a restricted Docker user Step 3: Setting up a Docker Bridge Network Following these guides will give you a nice Docker folder structure, a restricted user to run your containers on (this is more secure) and a dedicated network for your containers. Lets Begin First we need to set up some folders for RustDesk to save its configuration files and also where the Project will save th
Recently I had to move 80 or so virtual servers from one subnet to another. The server's all have their IP's assigned via DHCP, and they keep them via DHCP reservations. I also need to make the IP's reserved in the new scope.
This should be easy peasey.
I just need to use netsh to export the DHCP scope in question, do a find and replace to change the address, and re-import.
First, let's review the syntax for using the netsh export command.
Wait a minute, there's a note on the netsh.exe dhcp command documentation:
Remarks
Well, doesn't that just suck that the DHCP service has to stop. Not quite as easy peasey as I hoped.
That leads us to the DUMP command:
dump
So using the DUMP command, you dump the entire config, and just copy the bits that you need, and reimport them.
So running the command (from an administrative command prompt):
C:\Users\Administrator>netsh dhcp server dump > dhcpcfg.txt
generates a file in that directory from the local dhcp server.
Open up the file, and find the ReservedIP section for the scope you are interested in. It's very human readable, you shouldn't have any problem finding it.
The section of the file I wanted appears like this (of course I sanitized it):
So I copy JUST this section to another blank text file so I can edit.
Let's cover the syntax:
The stuff surrounded in == and # are just comments, they're there to help a human read the file. Nothing more.
Dhcp Server 10.0.0.20
Dhcp Server \\DHCPSrv1
Dhcp Server \\DHCPSrv1.example.com
These are connection methods to identify the DHCP server, The first via IP, the second via NetBIOS, the third via FQDN. Normally they would all be the same, I just did three to show the three different ways.
Scope 10.0.10.0 Add reservedip
Identifies the scope you want to edit, and what you want to do.
10.0.10.22 001122334456 "Server2" "Web Server"
The IP address you want to reserve, the MAC address it's bound to, The Reservation Name, the Reservation Description (Which is optional).
"BOTH"
Specifies the type of clients to associate with this reserved client entry. The options are {DHCP | BOOTP | BOTH} DHCP is the default.
Now that you have your file all fixed up, you need to import it back in.
You have a few options.
I'm not going to cover the netsh import command, because it's going to stop the DHCP server. Not good, I want to do this live, with no impact on my normal clients.
Use netsh exec to import the configuration changes
C:\Users\Administrator>netsh exec dhcpcfg-edited.txt
This should be easy peasey.
I just need to use netsh to export the DHCP scope in question, do a find and replace to change the address, and re-import.
First, let's review the syntax for using the netsh export command.
- First you launch a netsh command prompt C:\Users\Administrator>netsh.exe
netsh> - Now that you have a Netsh command prompt, navigate to the DHCP commands.
dhcp server \\servername - Now issue the export command. The following command exports the full service configuration to the c:\Temp\Dhcpdb file:
export c:\temp\dhcpdb all
The following command exports the configuration that pertains to scopes 10.0.0.0 and 20.0.0.0 to the c:\Temp\Dhcpdb file:
export c:\temp\dhcpdb 10.0.0.0 20.0.0.0
Wait a minute, there's a note on the netsh.exe dhcp command documentation:
Remarks
This command works only on the local server.
While the export command runs, the DHCP service is stopped and does not respond to DHCP clients seeking new leases or lease renewals.
If the DHCP service has a large number of scopes or a large number of client address leases, this command can take a long time to run.
Well, doesn't that just suck that the DHCP service has to stop. Not quite as easy peasey as I hoped.That leads us to the DUMP command:
dump
Dumps the configuration of the local DHCP server to the command prompt window when run within the netsh environment.
So using the DUMP command, you dump the entire config, and just copy the bits that you need, and reimport them.So running the command (from an administrative command prompt):
C:\Users\Administrator>netsh dhcp server dump > dhcpcfg.txt
generates a file in that directory from the local dhcp server.
- Note, you should be able to run the command remotely, but apparently there is/was a bug that prevented windows 7 and vista from accessing that command. Works fine on XP and 2000 however. Go figure
Open up the file, and find the ReservedIP section for the scope you are interested in. It's very human readable, you shouldn't have any problem finding it.
The section of the file I wanted appears like this (of course I sanitized it):
# ======================================================================
# Start Add ReservedIp to the Scope : 10.0.10.0, Server : 10.0.0.20
# ======================================================================
Dhcp Server 10.0.0.20 Scope 10.0.0.0 Add reservedip 10.0.10.21 001122334455 "Server1" "" "DHCP"
Dhcp Server \\DHCPSrv1 Scope 10.0.10.0 Add reservedip 10.0.10.22 001122334456 "Server2" "Web Server" "BOTH"
Dhcp Server \\DHCPSrv1.example.com Scope 10.0.10.0 Add reservedip 10.0.10.23 001122334457 "Server3" "ISA Server" "BOTH"
So I copy JUST this section to another blank text file so I can edit.
Let's cover the syntax:
The stuff surrounded in == and # are just comments, they're there to help a human read the file. Nothing more.
Dhcp Server 10.0.0.20
Dhcp Server \\DHCPSrv1
Dhcp Server \\DHCPSrv1.example.com
These are connection methods to identify the DHCP server, The first via IP, the second via NetBIOS, the third via FQDN. Normally they would all be the same, I just did three to show the three different ways.
Scope 10.0.10.0 Add reservedip
Identifies the scope you want to edit, and what you want to do.
10.0.10.22 001122334456 "Server2" "Web Server"
The IP address you want to reserve, the MAC address it's bound to, The Reservation Name, the Reservation Description (Which is optional).
"BOTH"
Specifies the type of clients to associate with this reserved client entry. The options are {DHCP | BOOTP | BOTH} DHCP is the default.
Now that you have your file all fixed up, you need to import it back in.
You have a few options.
- The easiest option is to launch the netsh.exe command from a command window, and just paste the file into the command window. This works best for small changes.
- Import the configuration changes using the netsh import command. Crap, the import command stop's the DHCP server as well.
- Import the configuration changes using the netsh exec command.
I'm not going to cover the netsh import command, because it's going to stop the DHCP server. Not good, I want to do this live, with no impact on my normal clients.
Use netsh exec to import the configuration changes
C:\Users\Administrator>netsh exec dhcpcfg-edited.txt
Thanks for this post, together with http://social.technet.microsoft.com/Forums/windowsserver/en-US/4c0a2dc4-74b2-43ed-b05c-710c9c2e3b25/netsh-command-error-the-command-needs-a-valid-scope-ip-address?forum=winserverNIS this was really helping us to import our 20+ dhcp reservations from SBS 2003 to SBS 2011.
ReplyDeleteExcellent post, thanks very much. Saved me a lot of time
ReplyDeleteThanks a lot for this mate, great job!
ReplyDeleteGreat Information, but in the Agency I work, We the Hetwork Engineers are responcible for IPAM, we manage the DHCP servers via MMC access normally. The export and import commands only work when using netsh on the local host; when attempting to run the export from another server or my desktop I would get the following error:
ReplyDeletenetsh dhcp server scope>export c:\temp\MyFile
DHCP Server import and export are allowed on local servers only.
Error 87 in FormatMessageW()
Parameter(s) passed are either incomplete or invalid.
netsh dhcp server scope>
But you gave me enough to find the show reservedip command and the add reservedip commends to make it work.
Just have to copy paste from the shell to text edit it and paste it back. Was only 100 reservations in a single scope, this time!
There is a note about that about that about halfway thru my Blog post
DeletePerfect post, thanks.
ReplyDeleteUse this. from another site to automate it in a for loop
ReplyDeletefor /f "tokens=1-6 delims=," %G IN (lists.txt) do netsh dhcp server \\server scope %G add reservedip %H %I %J %K %L
Thank you very much, for this guide! This helped me out immensely when I had to migrate DHCP scopes from a Server 2008 R2 server to a Server 2008 DHCP server!
ReplyDeleteWonderful post! Saved me from recreating 65 scopes and hundreds of reservations!!! Thank you very much.
ReplyDeleteIf you were using this command to increase change the subnet mask (increase the scope range), you need to delete the scope before re-importing it.. Wouldn't deleting the scope clear all the current DHCP leases and therefore cause IP clashes when clients requested IP numbers?
ReplyDelete