For Managed Service Providers (MSPs), IT support firms, call centers, and software export houses operating across Pakistan, reliable remote desktop software is mission-critical infrastructure. Technicians in Lahore, Karachi, and Islamabad manage thousands of end-user endpoints, troubleshoot cloud servers, and provide 24/7 technical assistance to clients across the US, UK, and the GCC.
However, relying on traditional proprietary remote desktop platforms—most notably TeamViewer and AnyDesk—has become an operational and financial liability in Pakistan.
Technicians routinely face aggressive algorithmic “Commercial Use Detected” triggers that terminate active support sessions after 60 seconds. Compounding the friction, enterprise licensing costs priced in US Dollars ($500 to $2,500+ per technician annually) place severe strain on operational budgets under PKR currency devaluation and State Bank of Pakistan (SBP) corporate foreign exchange quotas. Crucially, routing sensitive corporate and client screen data through third-party multitenant relays in Europe or Singapore introduces massive packet latency (180ms–280ms) and fails stringent client data privacy regulations.
The definitive industry solution is RustDesk: an open-source, end-to-end encrypted remote desktop platform that gives you complete architectural sovereignty. By deploying private RustDesk Rendezvous (hbbs) and Relay (hbbr) servers on a dedicated Linux Cloud VPS, Pakistani IT enterprises eliminate subscription licensing fees, guarantee absolute session privacy, and achieve blazing-fast sub-20ms remote control responsiveness over local fiber networks.
This technical blueprint walks through the entire architecture, containerized deployment, firewall tuning, client auto-configuration, and enterprise scaling for self-hosted RustDesk infrastructure.
1. RustDesk Architecture: Rendezvous vs. Relay Mechanics
To run a reliable remote support fleet, system administrators must understand how RustDesk negotiates connections between the Controller (Technician) and the Controlled Client (End User).
┌────────────────────────────────────────────────────────┐
│ SELF-HOSTED LINUX VPS INFRASTRUCTURE │
│ │
│ ┌────────────────────────┐ ┌────────────────────┐ │
│ │ hbbs (ID/Rendezvous) │ │ hbbr (Relay) │ │
│ │ Ports: 21115, 21116 │ │ Ports: 21117 │ │
│ └───────────▲────────────┘ └─────────▲──────────┘ │
└───────────────┼─────────────────────────┼──────────────┘
│ │
1. Register ID │ │ 3. Fallback Encrypted
& Punch Hole │ │ Relay Tunnel
│ │ (If CGNAT Blocks P2P)
┌──────────────────────┴───────┐ │
│ │ │
┌──────────┴───────────────┐ Direct P2P Session ┌───────┴────────────────┐
│ Technician Terminal │◄══════════════════════►│ Client Remote PC │
│ (RustDesk Controller) │ 2. Direct UDP Punch │ (RustDesk Agent) │
│ [Lahore / Islamabad] │ (Sub-15ms Latency) │ [Karachi / Remote UK] │
└──────────────────────────┘ └────────────────────────┘
The RustDesk server ecosystem consists of two core binaries compiled in Rust:
hbbs (Heartbeat & Rendezvous Server)
- ID Registration: Listens for incoming connection announcements from clients and assigns unique cryptographic IDs.
- NAT Traversal & Hole Punching: Acts like a STUN/ICE broker. It detects external public IP/port mappings and orchestrates direct Peer-to-Peer (P2P) UDP hole punching between the controller and the client.
- Security & Verification: Validates that incoming clients possess the correct private/public keypair, rejecting unauthorized endpoints.
hbbr (Relay Server)
- Encrypted Relay Fallback: In environments where direct P2P hole punching fails—such as when clients sit behind restrictive enterprise firewalls, Symmetric NATs, or aggressive Carrier-Grade NAT (CGNAT) pools frequently deployed by Pakistani mobile operators (Jazz, Zong) and regional wireless ISPs—the traffic is transparently redirected through
hbbr. - Zero Decryption: The relay server acts strictly as an opaque byte pipe. Because session payloads are encrypted end-to-end with ChaCha20-Poly1305 and asymmetric Ed25519 keys, the relay server cannot inspect screen buffers, mouse movements, or file transfers.
2. Server Sizing & Resource Allocations
RustDesk is written in Rust and is exceptionally lightweight compared to Java or Python-based alternatives. However, bandwidth and network packet scheduling matter far more than raw CPU compute:
| Deployment Tier | Concurrent Relay Sessions | Supported Client Endpoints | Recommended Hardware Spec | Network Bandwidth |
|---|---|---|---|---|
| Tier 1: Boutique MSP / Dev Agency | Up to 15 Active Relays | 100–300 Machines | 2 vCPU, 2 GB RAM, 30 GB NVMe | 1 Gbps Shared (1 TB Egress) |
| Tier 2: Mid-Market IT Support / BPO | Up to 80 Active Relays | 500–2,000 Machines | 4 vCPU, 8 GB RAM, 80 GB NVMe | 1 Gbps Dedicated (5 TB Egress) |
| Tier 3: Enterprise Call Center Fleet | 200+ Active Relays | 5,000+ Machines | 8+ Dedicated vCPU or Bare Metal | 10 Gbps Unmetered Uplink |
[!NOTE] During direct P2P connections, the server consumes virtually zero bandwidth once the initial handshake finishes. The server only consumes sustained bandwidth (approximately 0.5 Mbps to 2.5 Mbps per session, depending on screen resolution and frame rate) when a connection falls back to the
hbbrrelay.
For mission-critical IT support fleets handling high-density video streaming or multi-technician screen sharing across distributed branches, provisioning high-frequency compute on dedicated bare metal ensures zero packet queuing. Explore our full array of enterprise Dedicated Servers for unthrottled gigabit throughput, or deploy localized bare metal instances via our high-speed Dedicated Servers in Pakistan for minimal domestic routing hops.
3. Production Deployment with Docker Compose
Using Docker Compose ensures container immutability, automated restart policies, and clean volume isolation for encryption keys and logs.
Step 1: Prepare System and Directory Structure
Log into your Ubuntu 24.04 or Debian 12 cloud server via SSH and prepare the runtime environment:
# Update package repositories and install prerequisites
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git ufw fail2ban ca-certificates apt-transport-https
# Install Docker Engine & Compose plugin
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Create directory structure for RustDesk server data
sudo mkdir -p /opt/rustdesk/data
cd /opt/rustdesk
Step 2: Configure docker-compose.yml
Create the Compose specification. In this configuration, replace relay.yourdomain.pk with your actual Fully Qualified Domain Name (FQDN) or your server’s static public IPv4 address:
version: '3.8'
networks:
rustdesk-net:
driver: bridge
services:
hbbs:
container_name: rustdesk-hbbs
image: rustdesk/rustdesk-server:latest
environment:
- ALWAYS_USE_RELAY=N
command: hbbs -r relay.yourdomain.pk:21117 -k _
volumes:
- ./data:/root
networks:
- rustdesk-net
ports:
- "21115:21115"
- "21116:21116"
- "21116:21116/udp"
- "21118:21118"
depends_on:
- hbbr
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "20m"
max-file: "5"
hbbr:
container_name: rustdesk-hbbr
image: rustdesk/rustdesk-server:latest
command: hbbr -k _
volumes:
- ./data:/root
networks:
- rustdesk-net
ports:
- "21117:21117"
- "21119:21119"
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "20m"
max-file: "5"
[!IMPORTANT] Notice the
-k _parameter appended to bothhbbsandhbbr. This flag enforces strict public key authentication. Without-k _, your server will run in “open relay” mode, allowing any random RustDesk user on the public internet to abuse your server’s bandwidth as a free proxy. The underscore_instructs RustDesk to automatically load the server’s private key (id_ed25519) from the/rootvolume.
4. Network Port Topology & Firewall Hardening
One of the most frequent reasons why self-hosted RustDesk deployments fail with a "Not Ready. Please check your network connection" error is the misconfiguration of UDP port 21116.
Here is the exact port breakdown required by the RustDesk service stack:
| Port | Protocol | Service | Direction | Operational Function |
|---|---|---|---|---|
| 21115 | TCP | hbbs |
Inbound | NAT type test and peer mapping detection |
| 21116 | TCP | hbbs |
Inbound | TCP hole punching and connection negotiation |
| 21116 | UDP | hbbs |
Inbound | CRITICAL: ID registration, heartbeat & keep-alive |
| 21117 | TCP | hbbr |
Inbound | Encrypted relay tunnel traffic |
| 21118 | TCP | hbbs |
Inbound | Web client WebSocket listener (optional) |
| 21119 | TCP | hbbr |
Inbound | Web client WebSocket relay (optional) |
Hardening Linux with UFW (Uncomplicated Firewall)
Run the following commands to open only the required RustDesk ports while safeguarding administrative SSH:
# Allow administrative SSH (ensure custom port if altered)
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp comment 'SSH Administrative Access'
# Allow RustDesk Core Communication
sudo ufw allow 21115:21119/tcp comment 'RustDesk TCP Ports'
sudo ufw allow 21116/udp comment 'RustDesk UDP Rendezvous Registration'
# Enable firewall
sudo ufw enable
sudo ufw status verbose
5. Starting the Service & Key Extraction
Once the firewall is active, launch the containers:
cd /opt/rustdesk
docker compose up -d
Verify that both containers are running healthy:
docker compose ps
Retrieving Your Public Key
During the first initialization, hbbs generates an asymmetric Ed25519 keypair inside the ./data volume (id_ed25519 for the private key and id_ed25519.pub for the public key).
Inspect and copy your public key string:
cat /opt/rustdesk/data/id_ed25519.pub
You will see a base64 string similar to:
Qk892LxZ92kL+vK8K32mO0W/JqLmO52XkP91M=
This public key string is what you will distribute to your technicians and client devices. Without it, clients cannot authenticate against your private hbbs rendezvous server.
6. Client Deployment & Zero-Touch Packaging
To connect to your private server, technicians and end users need two parameters:
- ID Server:
relay.yourdomain.pk(or your VPS static IP) - Key: The string copied from
id_ed25519.pub
Manual Client Configuration
- Open the RustDesk client application on Windows, macOS, or Linux.
- Click the three dots (Menu) beside the ID display -> Settings -> Network.
- Click Unlock network settings and enter:
- ID Server:
relay.yourdomain.pk - Relay Server:
relay.yourdomain.pk(or leave empty if using default port 21117) - API Server: Leave blank (used only in RustDesk Pro)
- Key:
<Paste your id_ed25519.pub string>
- ID Server:
- Click Apply. At the bottom of the main interface, the status will immediately switch from “Connecting to public network” to a green indicator stating “Ready”.
┌────────────────────────────────────────────────────────┐
│ RUSTDESK CLIENT NETWORK SETUP │
├────────────────────────────────────────────────────────┤
│ ID Server: [ relay.yourdomain.pk ] │
│ Relay Server: [ relay.yourdomain.pk ] │
│ API Server: [ ] │
│ Key: [ Qk892LxZ92kL+vK8K32mO0W/JqLmO52Xk... ] │
├────────────────────────────────────────────────────────┤
│ Status: ● Ready (Direct Server Connected) │
└────────────────────────────────────────────────────────┘
Zero-Touch MSI / Exe Renaming for Pakistani End Users
For non-technical clients across Pakistan who cannot navigate manual settings menus, RustDesk supports automatic configuration via executable file naming.
You can package and distribute the Windows installer by renaming the .exe file using the following convention:
rustdesk-host=relay.yourdomain.pk,key=Qk892LxZ92kL+vK8K32mO0W...=.exe
When the client double-clicks this binary, the installer automatically parses its own filename, populates the private ID and Key settings in the registry, and launches directly connected to your private server—requiring zero user intervention.
7. Performance Benchmarks: Self-Hosted VPS vs. Proprietary Cloud
Why does hosting your own RustDesk node drastically outperform public commercial remote desktop services for Pakistani users? The answer lies in network routing and subsea cable architecture.
┌───────────────────────────────────────────────────────────────────────────┐
│ REMOTE DESKTOP ROUND-TRIP TIME (RTT) COMPARISON │
├───────────────────────────────────────────────────────────────────────────┤
│ Proprietary Commercial Cloud (TeamViewer / AnyDesk EU Relay) │
│ [Lahore Tech] ──► [Suez Subsea / Marseilles] ──► [Frankfurt Relay] ──► │
│ ──► [Return Route to Karachi Client] : ~190ms - 240ms Latency │
├───────────────────────────────────────────────────────────────────────────┤
│ Self-Hosted Linux Cloud VPS (Local BGP Peering in Pakistan / GCC) │
│ [Lahore Tech] ──► [Local Internet Exchange / PIX Core] ──► │
│ ──► [Karachi Client Direct P2P] : ~12ms - 25ms Latency │
└───────────────────────────────────────────────────────────────────────────┘
Telemetry Benchmarks
- Local Keystroke to Display Echo: Drops from ~220ms on overseas shared relays down to sub-25ms on a localized VPS. Technicians experience fluid 60 FPS screen redraws without typing rubber-banding or cursor trailing.
- Large File Transfer Speeds: On proprietary platforms, peer-to-peer file transfers are frequently throttled to 200–500 KB/s on non-licensed tiers. On a dedicated 1 Gbps cloud server, file transfers utilize the full bandwidth of the client’s local broadband line (10–50 MB/s).
- Session Reconnection Stability: During local Pakistani ISP routing re-convergences, self-hosted UDP heartbeats re-establish dropped sessions in under 1.5 seconds, whereas public multi-tenant clouds often leave technicians waiting for timeout re-authentications.
8. Enterprise Production Runbook: Automation & Maintenance
To maintain five-nines (99.999%) availability for enterprise remote support operations, incorporate these sysadmin maintenance practices:
1. Automated Systemd Container Supervision
Ensure your containers survive unexpected host power cycles or kernel updates by verifying Docker’s systemd daemon status:
sudo systemctl enable docker
sudo systemctl is-active docker
2. Log Rotation to Prevent Disk Saturation
If running hundreds of concurrent support sessions, hbbs and hbbr stdout can generate gigabytes of log output over time. In Section 3, we implemented max-size: "20m" and max-file: "5" within Docker Compose. Verify log file hygiene periodically:
# Check container log disk utilization
du -sh /var/lib/docker/containers/*/*-json.log
3. Automated Offsite Backup of Cryptographic Keys
Your server’s entire operational identity resides in /opt/rustdesk/data/id_ed25519. If this key is lost, every deployed client agent in your organization will be orphaned and must be reconfigured.
Create a nightly automated backup script:
#!/usr/bin/env bash
BACKUP_DIR="/var/backups/rustdesk"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p "$BACKUP_DIR"
tar -czf "$BACKUP_DIR/rustdesk_keys_$TIMESTAMP.tar.gz" -C /opt/rustdesk/data id_ed25519 id_ed25519.pub
# Retain backups for 30 days
find "$BACKUP_DIR" -type f -name "*.tar.gz" -mtime +30 -delete
Add this script to your root crontab to execute every night at 02:00 AM:
0 2 * * * /usr/local/bin/backup-rustdesk.sh >/dev/null 2>&1
9. Conclusion: Take Full Control of Your IT Operations
Proprietary remote support software has become an unpredictable expense and operational bottleneck for modern Pakistani technology companies. Transitioning to a self-hosted RustDesk deployment on enterprise cloud infrastructure gives your firm:
- Total Cost Elimination: Zero annual per-seat licensing fees or unpredictable USD conversion fees.
- Sovereign Security & Compliance: Cryptographic keys remain strictly on your private hardware, keeping customer data secure.
- Ultra-Low Latency: Exceptional local responsiveness that elevates your IT support quality above competitors.
Deploy your high-uptime, unmetered Linux Cloud VPS or enterprise-grade Pakistan Dedicated RDP Workstations with Nextgen Hosting today, backed by local 24/7 network engineering support.
Deploy Your High-Performance RustDesk VPS Today
Eliminate TeamViewer and AnyDesk commercial timeouts forever. Deploy your private RustDesk server on Nextgen Hosting’s ultra-fast NVMe Cloud VPS or bare-metal dedicated servers with pure 1 Gbps unmetered bandwidth, clean static IPs, and sub-20ms Pakistani fiber routing.
