Izbornik Zatvoriti

Setting up self hosted RustDesk server on Windows

Skraćena veza: https://pedja.supurovic.net/veza/10515

RustDesk remote desktop

RustDesk (https://rustdesk.com/ , https://github.com/rustdesk ) is Open source virtual/remote desktop software like TeamViewer or AnyKey. It is on par with them in functionality, except that RustDesk is Open software, meaning free. It gains large popularity, as it does job well, and especially because commercial alternatives became unreasonably expensive unacceptable for noncommercial or low profile use.

Actually, there is one more big difference – You can host RustDesk on your own. This makes you independent from third parties. It makes it even more favorable.

Author of RustDesk actually recommends using self hosted servers for simple reason – public servers that are available, and free to use, actually do cost money. Switching to self hosted servers lowers costs of public servers.

How it works

Simplified said, you run two RustDesk Clients so they connect to RustDesk host. If you want access to other client you have to use it’s ID to connect to it. All communication goes through RustDesk host. Clients can be behind NAT routers as they do not communicate directly, but they use connections to the host.

This of, course, can also work in local network, without need of Internet. There is also option that clients, if they realize they actually can see each other, switch to communicate directly, without use of a host.

Requirements

Being independent means you are becoming responsible for providing resources and availability of the service. For small scale needs, that is not huge requirements and is perfectly doable. What you must have is modest computer available to install server and reasonable Internet connection.

If you need to allow connections to your local server from public Internet, internet connection, public IP and options to set NAT are must. You also can alternatively use some small scale bare bone hosting or cloud service. Server works fine on Linux and Windows platforms.

What is needed

At RustDesk site you will find instructions for several ways to install server on supported platforms. I will be practical and focus on just one, that I did. As installation did not go smooth until I understand lots of stuff that were new to me, I am writing this down as notes to myself but I hope other could gain from it.

As RustDesk host should run as an service the first you need NSSM (Non-Sucking Service Manager). It’s name is appropriate. It really makes installing service easy and neat. You can get it from http://nssm.cc/ .

Other thing you need is actualy RustDesk server. You can get it from https://github.com/rustdesk/rustdesk-server/releases/tag/1.1.6. That is version that is actual now, but you should check if there is newer version. Beware that Windows compiled binaries are not promptly available for all versions.

Presumptions

Lets assume you have local network and you want to allow RustDesk clients to access each other both in public and local network. That means you have local Windows PC that will act as RustDesk server and internet connection with static public IP address. Local network is behind NAT router. You will use dedicated domain for service named rustdesk.mydomain.org. You have a router which allows you to set NAT rules and that also acts as DNS for local network with option to set static DNS entries.

Here are so many variations that can apply here so we will not go more into details. I assume that if you are going to install RestDesk server you know enough about networking, and can manage with information provided in this tutorial.

Installation

Installation goes in few steps.

Setting up network

Set up domain rustdesk.mydomain.org to point to public IP address assigned to your router. That would allow clients from internet to search for the server in your network. Lets assume that rustdesk.mydomain.org points to IP 94.214.56.108. That is address that all RustDesk clients located on Internet should connect to to access your self hosted RustDesk Server.

Make sure local computer, that is going to became server, is set to static IP address. It is important that that address does not change. You can do it by assigning IP in DHCP server on router or by assigning IP manually to the network interface on computer. Let’s assume that local IP is 192.168.1.4. That is address all RustDesk clients within local network should use to access your self hosted RustDesk Server.

Set NAT rules in router to forward incoming connections on TCP ports 21115 to 21119 and 8000 and UDP port 21116 to point to local IP address you assigned to the server computer.

Make static DNS entry in router that would point domain rustdesk.mydomain.org to local IP address you assigned to the server (assumed to be 192.168.1.4). This allows clients in your local network to also see the server on that domain. Although domain is the same, IP address they get would be different from IP that clients on the public Internet would see. What matters is that they deal with the same domain.

Possible simplification

You can simplify this settings if you set RustDesk server outside of your network, on some bare bone hosting or cloud server.  That way you will not have to deal with router, NAT and static DNS. Your server would have public IP, visible from everywhere, and you would simply point domain rustdesk.mydomain.org to that IP.

Unpacking

Create directory somewhere on the disk to store RustDesk server files. It may be any directory as long as it is accessible. Let’s say we choose it to be C:\RustDeskServer\.

Download NSMM and extract nsmm.exe to this directory. You will find 32bit and 64bit version in downloaded archive. Choose appropriate one. Just place nsmm.exe into C:\RustDeskServer\.

Downloaded archive of RustDesk server will contain just two files: nbbr.exe and nbbs.exe. Extract them both into C:\RustDeskServer\.

Setting up host

Open command prompt and position it to the install directory using command:

cd C:\RustDeskServer\

Install RustDesk router service first

nssm.exe install "RustDesk hbbr service" C:\RustDeskServer\hbbr.exe -k _

Then install Rendezvous server

nssm.exe install "RustDesk hbbs service" C:\RustDeskServer\hbbs.exe -r rustdesk.mydomain.org -k _

Note that you have to use full path to service executables.

Both services should install without error. Then you start them

nssm.exe start "RustDesk hbbr service"
nssm.exe start "RustDesk hbbs service"

And that is it. You installed RustDesk Server.

Check if there is firewall on computer that prevents accessing server ports (TCP ports 21115 to 21119 and 8000 and UDP port 21116). Those should be accessible from the local network and also from internet through the NAT router. For TCP ports you can simply try telnet to server address and chosen port. If it connects that means port is accessible. If one port is accessible, that usually means all ports are.

Side notes

When starting services there are two parameters used.

-k specifies that client must use public security key. Clients that do not have key or have wrong key would not be accepted.

If you omit this parameter when starting service, keys would not be required, or better say, they wold be ignored. All connections would be insecure.

However, to connect to specified self hosted server, client still has to have security key in file name. In that case key may be anything as it would be ignored. It is strongly recommended to enforce usage of security keys, like this tutorial shows.

-r specifies address of rendezvous server. It actually may be a list of servers. It seems that when client connects to host it returns this list of rendezvous servers for clients to use to connect to each other. In other tutorials I found out that ip address 0.0.0.0 is used for this purpose. I guess it has special meaning, maybe that rendezvous server is the same as router server.

Well, in this configuration with clients on both sides of NAT that 0.0.0.0 address does not work. Clients cannot connect to each other. I solved this by using domain instead of IP. As domain is set to point to different IP regarding if client is on Internet or in local network, that meant they all connected properly to rendezvous server and they could connect to each other.

As this parameter accepts list of addresses, it is possible that it would work if both public and local IP address are listed so that client would use one it can access. I did not test that way as I do not like hard coding IP addresses. I like to use domains instead.

I guess this is not an issue if RustDesk host is directly on public IP as then all clients would see it the same. Lets say this is quirk important for hosting RustDesk behind NAT.

Setting up RustDesk Client

RustDesk client has to be set up to access your self hosted RustDesk Server.

First, make sure you have no RustDesk Client installed. That is important! This cannot work with RustDesk client that is installed. You have to use Portable version. If you have installed RustDesk Client deinstall it (do not worry, you will not loose ID).

Download portable RustDesk Client from https://rustdesk.com/ and unpack rustdesk.exe (it would probably have version number in file name) wherever you want. Desktop would be fine. RustDesk Client version I did this with is 1.1.9.

RustDesk Client by default connects to the public host, but we need it to connect to our local host so we have to set it up. It is a bit unusual, but configuration is done by changing file name.

Filename should contain two information: address of the host and security key. Address of the host is domain we already prepared – rustdesk.mydomain.org.

To get a security key check content of the directory where server is located – C:\RustDeskServer\. Two new files should be there that are created when server was installed: id_ed25519 and id_ed25519.pub. Those are private and public keys for secure connection.

Open id_ed25519.pub in some text editor and copy line of character that is inside. That is security key. Lets say key looks like this: rvIZyRt2259R3OklpnjPHxKOruTuOJAYKG4fkdwKcNI=

Copy rustdesk.exe to a file with new name:

rustdesk-host=rustdesk.mydomain.org,key=rvIZyRt2259R3OklpnjPHxKOruTuOJAYKG4fkdwKcNI=.exe

Yes I know, looks odd, but that is how it is supposed to look. Now, when you run this program it will check it’s own exe name and extract address of the host and security key (That is interesting way to keep configuration within single file, right?).

So, you now can copy this file to any computer you want to use your RustDesk Server.

Important note: check if security key contains some characters that are not allowed to be used in Windows file name like ~ “ # % & * : < > ? / \ { | } or so. If it does contain such characters the you would not be able to name file.

To resolve this, stop RustDesk Server using these commands:

nssm.exe stop "RustDesk hbbr service"
nssm.exe stop "RustDesk hbbs service"

While they are stopped delete files id_ed25519 and id_ed25519.pub and then start services again.

nssm.exe start "RustDesk hbbr service"
nssm.exe start "RustDesk hbbs service"

That would create new files. Check content of id_ed25519.pub and if it is not suitable, just repeat process. Unsuitable characters show rarely.

So how to use it?

Using RustDesk Client with self hosted server is the same as with public server. The only difference is that you use different sever.

Remember, only clients connected to the same server can communicate. So when, you need to access someone else’s PC, just send to him file rustdesk-host=rustdesk.mydomain.org,key=rvIZyRt2259R3OklpnjPHxKOruTuOJAYKG4fkdwKcNI=.exe (of course your file would have different name) and let him use that to connect to your server.

Problems?

Well yes, there may be a problems. Due to way RustDesk Client works it is not possible to run two clients connecting different servers at the same time. Yes, you can run RustDesk Client multiple times and connect it to several remote clients at the same time as long as all are connecting to the same server.

Most usual issue is that someone already has installed RustDesk Client that connects to public server. If that is the case he must deinstall that client. If he needs to connect to public server too, he can just copy exe you provided into new file named rustdesk.exe. That one would be portable and it would connect to the public server. He just must may attention that he cannot have running two clients connected to self hosted and public server at the same time. One that is run first would work, other one would go crazy.

Once RustDesk Client is started it is hart to tell which one it is. There is no visual clues to let you know which server you are connected to. You may check About option, but it just shows if it is configured to use private server, but not that it is actually using it. I hope, author would deal with this in the future releases.

If you meet some other issue, it may help to check configuration and logs of RustDesk Client they are located in directory %appdata%\RustDesk.

11 Comments

  1. Emmanuel Cielo

    Hi, I have the same setup but it seems my external clients can’t see the host server. Can’t see meaning they can’t make their status ready, but they can connect to internal clients. Internal clients cannot also see the external clients. Anymore suggestions on how to set it up?

    • Peđa

      Check part of the article that explains using -r parameter when installing RustDesk server.

      Clients on local network see server on local IP. Clients on internet see server on public IP. I resolved it by using domain in -r parameter and assigning different IP to domain depending where from user accesses server.

      The other possible solution is to specify both local and public IP of the server in -r parameter. I did not try that.

      This assumes that NAT port forwardingis set properly. IF your clients do not show „Ready“ when connecting to server that implies they do not see server. Is ANT prot forwarding done properly?

      I can only guess until I see how RustDesk server. NAT and RustDesk clients are set.

  2. Zoltan

    Hello
    Thanks for your documentation ;)
    I have a problem with the client.
    I try to run the renamed exe without the key like this:
    „rustdesk-host=rustdesk.mydomain.org.exe.“ but when started not using my own server. (I see the „For faster connection…“ caption)
    What am I spoiling?
    thanks ;)

    • Peđa

      You must specify key. Without it, client ignores custom host settings and goes to public one.

      If you do not want to use keys, remove parameter „-k _“ (without quites from both commands to install services (hbbr and hbbs). If you have services already running, stop them, remove them and install again without -k parameter.

      That would set server to ignore keys. You still must specify key in exe name but it is ignored so you can use anything as a key.

      Remember that removing -k means loosing security level.

  3. Mo

    Dear I don’t have my own host , I want to use the free RustDesk. But only in LAN I can connect to the remote laptop Windows 10 (from my iphone 11 pro).
    But once I disable wifi on my iphone (4G with normal IPv4 address), i receive errormessages: Connection error keeps showing :

    first:
    broken pipe (os error 32)
    then:
    reset by the peer
    then repeats

    Please help?

  4. Mo

    Dear, thanks for your reply.
    I already checkt ports open or not wit PFPortschecker, I setup windows firewal to open the prots that Rustdesk needs, and I also setup te modem firewall.

    Still same error.

    What else can be the cause why Rustdesk refuge to connext if not on same LAN?

  5. Mo

    Dear, update about 4G, when I connect to vpn (nord vpn) on my Iphone while 4G is active and Wifi disabled, then Rustdesk connect to the laptop with ease.

    and it seems no port forward is needed to connect to rustdesk free app on laptop. I tested this for another laptop in LAN which nog yet portforward has been configured.

    I’m happy it works like this on phone 4G

Ostavite odgovor na Zoltan Odustani od odgovora

Vaša adresa e-pošte neće biti objavljena. Neophodna polja su označena *

Popunite izraz tako da bude tačan: *

Ovo veb mesto koristi Akismet kako bi smanjilo nepoželjne. Saznajte kako se vaši komentari obrađuju.