Skip to content

Restrict RDP Access to Tailscale Only

Introduction

By default, Remote Desktop may be accessible through your VPS's public IP address.

To improve security, we'll configure Windows Defender Firewall to:

  • Allow RDP connections from approved Tailscale IP addresses.
  • Allow RDP only through the Tailscale network interface.
  • Block RDP connections through other network interfaces, including the public-facing interface.
  • Disable existing firewall rules that allow unrestricted RDP access.

Once configured, only authorised devices connected through Tailscale will be able to access RDP.

Important

Do not proceed until you have successfully tested RDP through Tailscale. Keep your current RDP session open and make sure you have access to your VPS provider's web console in case you lose connectivity.

Step 1: Identify the Tailscale Network Interface

Open PowerShell as Administrator on your VPS.

Run the following command to identify the available network adapters:

Get-NetAdapter | Format-Table -AutoSize Name, InterfaceDescription, Status

Locate the Tailscale network adapter.

Next, identify the IP addresses assigned to your VPS:

Get-NetIPAddress -AddressFamily IPv4 | Format-Table -AutoSize InterfaceAlias, IPAddress

Note the following:

  • The Tailscale adapter name.
  • The VPS's Tailscale IP address.
  • The Tailscale IP addresses of the computers authorised to connect.

Step 2: Configure the Firewall Variables

We'll first identify the configured RDP port automatically:

$port = [int](Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp').PortNumber

Enter the name of your Tailscale network adapter:

$meshInterface = "Tailscale"

Note

Replace Tailscale with the actual adapter name if it is different.

Enter the Tailscale IP address assigned to your VPS:

$meshIP = "100.80.0.3"

Note

Replace the example with your actual VPS Tailscale IP address.

Enter the Tailscale IP addresses of the computer(s) authorised to connect:

$allowedClients = @("100.80.0.2")

Note

Replace the example with the actual Tailscale IP address of your computer. You can add additional authorised devices by separating their IP addresses with commas.

Identify the active network interfaces other than Tailscale:

$nonMeshInterfaces = @(Get-NetAdapter | Where-Object { $_.Status -eq 'Up' -and $_.Name -ne $meshInterface } | Select-Object -ExpandProperty Name)

Display the interfaces that will be restricted:

$nonMeshInterfaces

Make sure the public-facing network adapter is included and the Tailscale adapter is excluded.

Important

Keep the same elevated PowerShell window open throughout the remaining steps because these commands use the variables created above.

Step 3: Back Up the Existing Firewall Configuration

Before making changes, export the current Windows Firewall configuration:

netsh advfirewall export "$env:USERPROFILE\Desktop\firewall-before-mesh-rdp.wfw"

This creates a firewall backup on your VPS desktop.

Step 4: Disable Existing Unrestricted RDP Rules

UKNode may have existing firewall rules that allow RDP through the public network interface.

Disable the UKNode RDP rules:

Get-NetFirewallRule -DisplayName "UKNode RDP *" -ErrorAction SilentlyContinue | Disable-NetFirewallRule

Disable the built-in Windows Remote Desktop firewall rules:

Get-NetFirewallRule -DisplayGroup "Remote Desktop" -ErrorAction SilentlyContinue | Disable-NetFirewallRule

This prevents the existing rules from providing unrestricted RDP access.

Step 5: Remove Previously Created Tailscale RDP Rules

To avoid duplicate rules when repeating the configuration, remove the rules created by this tutorial:

Get-NetFirewallRule -DisplayName "RDP Mesh Only*" -ErrorAction SilentlyContinue | Remove-NetFirewallRule
Get-NetFirewallRule -DisplayName "RDP Non-Mesh Block*" -ErrorAction SilentlyContinue | Remove-NetFirewallRule

Step 6: Create Firewall Rules Allowing RDP Through Tailscale

Create a TCP rule:

New-NetFirewallRule -DisplayName "RDP Mesh Only Allow TCP" -Direction Inbound -Protocol TCP -LocalPort $port -LocalAddress $meshIP -RemoteAddress $allowedClients -InterfaceAlias $meshInterface -Profile Any -Action Allow

Create a UDP rule:

New-NetFirewallRule -DisplayName "RDP Mesh Only Allow UDP" -Direction Inbound -Protocol UDP -LocalPort $port -LocalAddress $meshIP -RemoteAddress $allowedClients -InterfaceAlias $meshInterface -Profile Any -Action Allow

These rules ensure that:

  • Connections must originate from an approved Tailscale IP address.
  • Connections must target the VPS's Tailscale IP address.
  • Connections must enter through the Tailscale network interface.

Step 7: Block RDP Through Other Network Interfaces

We will now explicitly block RDP through all active network interfaces other than Tailscale.

Create a TCP blocking rule:

New-NetFirewallRule -DisplayName "RDP Non-Mesh Block TCP" -Direction Inbound -Protocol TCP -LocalPort $port -InterfaceAlias $nonMeshInterfaces -Profile Any -Action Block

Create a UDP blocking rule:

New-NetFirewallRule -DisplayName "RDP Non-Mesh Block UDP" -Direction Inbound -Protocol UDP -LocalPort $port -InterfaceAlias $nonMeshInterfaces -Profile Any -Action Block

These rules prevent RDP connections through the public-facing network interface and other non-Tailscale interfaces.

Step 8: Verify the Firewall Rules

Check the Tailscale allow rules:

Get-NetFirewallRule -DisplayName "RDP Mesh Only Allow*" | Format-Table -AutoSize DisplayName, Enabled, Direction, Action

Check the non-Tailscale blocking rules:

Get-NetFirewallRule -DisplayName "RDP Non-Mesh Block*" | Format-Table -AutoSize DisplayName, Enabled, Direction, Action

Check that the original UKNode rules are disabled:

Get-NetFirewallRule -DisplayName "UKNode RDP *" -ErrorAction SilentlyContinue | Format-Table -AutoSize DisplayName, Enabled, Action

The expected configuration is:

Rule Expected status
RDP Mesh Only Allow TCP Enabled / Allow
RDP Mesh Only Allow UDP Enabled / Allow
RDP Non-Mesh Block TCP Enabled / Block
RDP Non-Mesh Block UDP Enabled / Block
Original UKNode RDP rules Disabled

Also check the Windows Firewall profiles:

Get-NetFirewallProfile | Format-Table -AutoSize Name, Enabled, DefaultInboundAction

The firewall should be enabled and inbound connections should be blocked by default. Check for other custom firewall rules allowing the configured RDP port before considering the configuration complete.

What's next?

The firewall rules are now configured to allow RDP through Tailscale and block it through other active network interfaces.

Continue to Test Your Tailscale RDP Connection to verify that the configuration works as expected.