Skip to main content

How to Install RustDesk on Your Synology NAS

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

Using Netsh to export and import DHCP reservations

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.


  1. First you launch a netsh command prompt C:\Users\Administrator>netsh.exe
    netsh>
  2. Now that you have a Netsh command prompt, navigate to the DHCP commands.
    dhcp server \\servername
  3. 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.


  1. 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.
  2. Import the configuration changes using the netsh import command.  Crap, the import command stop's the DHCP server as well.
  3. 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

Comments

  1. 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.

    ReplyDelete
  2. Excellent post, thanks very much. Saved me a lot of time

    ReplyDelete
  3. Thanks a lot for this mate, great job!

    ReplyDelete
  4. Great 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:
    netsh 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!

    ReplyDelete
    Replies
    1. There is a note about that about that about halfway thru my Blog post

      Delete
  5. Use this. from another site to automate it in a for loop

    for /f "tokens=1-6 delims=," %G IN (lists.txt) do netsh dhcp server \\server scope %G add reservedip %H %I %J %K %L

    ReplyDelete
  6. 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!

    ReplyDelete
  7. Wonderful post! Saved me from recreating 65 scopes and hundreds of reservations!!! Thank you very much.

    ReplyDelete
  8. If 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

Post a Comment

Most Popular Posts

First Post!

In August 1999, I bought my own domain name, mpking.com .  This domain name. Over the years I've used a variety of blogging software. Initially I did all the website design myself, hand crafting the HTML myself. I even had one of those *Designed by Notepad* buttons. I still have one of the custom drop cap letters I made. Yea, it's really hard to see, because it's White text.  My first website, like most all bad websites of the early 2000, was black theme.  I ran the website off my computer in my room. I quickly tired of this, and moved onto a Blog software platform.  You used an actual program program, (I don't remember it's name) and you would type up your entry, then upload it to the website.  That tired quickly, as the software was at home, and most entries, then as now, revolved around work. Then I discovered FreeGuppy .  It was online CMS platform, and it was nearly perfect, for almost five years.I even developed some plugin's for the product. A