
Remote Desktop Gateway (RD Gateway) is a Windows Server role that lets users reach computers on an internal network over the internet without opening port 3389 to the world. Users connect to the gateway over HTTPS on port 443; the gateway checks who they are and what they may reach, then forwards the Remote Desktop session to the internal PC or server. This guide explains how RD Gateway works, what you need, how to install and configure it on Windows Server 2019, 2022 or 2025, how to connect, and how to keep it secure.
Quick answerInstall the Remote Desktop Gateway role service, bind a trusted SSL certificate, create a connection authorization policy (RD CAP) for who may connect and a resource authorization policy (RD RAP) for what they may reach, allow TCP 443 (and optionally UDP 3391) through the firewall, then add the gateway's name under Advanced → Settings in Remote Desktop Connection.
How RD Gateway works
Without a gateway, each machine you want to reach needs its own RDP port exposed to the internet, which attracts constant password-guessing attacks. With a gateway:
- The client opens an encrypted HTTPS connection to the gateway (for example
rdg.example.com:443). - The gateway authenticates the user against Active Directory and checks the RD CAP.
- It checks the RD RAP to confirm the user may reach the requested internal computer.
- It relays the RDP traffic to that computer on the internal network.
Only the gateway is exposed. Internal machines keep RDP closed to the internet, and you get one place to log, audit and add multi-factor authentication.
What you need
- A server running Windows Server 2016, 2019, 2022 or 2025, joined to an Active Directory domain. (A workgroup setup with local groups is possible, but domain mode is the normal design.)
- A public DNS name for the gateway, such as
rdg.example.com, pointing to the server's public IP. - An SSL/TLS certificate for that name from a trusted certificate authority. A self-signed certificate works for testing but every client must trust it manually.
- Firewall rules allowing TCP 443 in (and UDP 3391 if you want the faster UDP transport).
- Remote Desktop enabled on the internal computers users will reach.
- Remote Desktop Services client access licences (RDS CALs) if users connect to session hosts; administration of servers is covered by the two built-in admin sessions.
Step 1: Install the RD Gateway role
In Server Manager, choose Manage → Add Roles and Features, select Role-based or feature-based installation, pick the server, tick Remote Desktop Services, and under role services select Remote Desktop Gateway. Accept the extra features it asks for (Network Policy and Access Services and IIS components) and install.
Or use PowerShell as administrator:
Install-WindowsFeature RDS-Gateway -IncludeManagementTools
If you are building a full Remote Desktop Services deployment with session hosts and RD Web Access, use the Remote Desktop Services installation option in the wizard instead, and add the gateway from the deployment overview.
Step 2: Bind the SSL certificate
Open RD Gateway Manager (Server Manager → Tools → Remote Desktop Services → Remote Desktop Gateway Manager). Right-click the server name, choose Properties, and open the SSL Certificate tab. Choose Import a certificate into the RD Gateway and select the certificate for your gateway name, or import a .pfx file first.
The name on the certificate must match the name clients will type. A mismatch is the most common reason connections fail with a certificate warning.
Step 3: Create the RD CAP (who can connect)
In RD Gateway Manager, expand Policies, right-click Connection Authorization Policies and choose Create New Policy → Wizard. The wizard creates both policies:
- Name the CAP and add the user groups allowed to use the gateway, for example a
RDG-Usersgroup. Avoid "Domain Users". - Choose password and/or smart card authentication.
- Under device redirection, disable what you do not need (for example drives or clipboard) for tighter security.
- Set idle and session timeouts.
Step 4: Create the RD RAP (what they can reach)
The wizard continues with the resource policy. Choose the user groups again, then the computers they may reach. Use an Active Directory group of computers (for example RDG-Targets) rather than "Allow users to connect to any network resource". Keep the allowed port at 3389 unless your internal machines use a different port.
Step 5: Open the firewall
Windows adds rules for the gateway during installation. On your network or provider firewall, allow TCP 443 to the gateway, and UDP 3391 if you want UDP transport. Port 3389 does not need to be open to the internet at all.
Step 6: Connect through the gateway
In Remote Desktop Connection (mstsc):
- Click Show Options, open the Advanced tab, and click Settings under "Connect from anywhere".
- Choose Use these RD Gateway server settings and enter
rdg.example.com. - Leave Use my RD Gateway credentials for the remote computer ticked if the same account is used for both.
- Back on the General tab, enter the internal computer name (for example
pc01.corp.example.com) and connect.
The same gateway setting is available when adding a PC in the Windows App and in Remote Desktop clients for macOS, iOS and Android. In a saved .rdp file it is the gatewayhostname:s:rdg.example.com line.
Securing RD Gateway
- Patch it. RD Gateway is internet-facing, so install Windows security updates promptly.
- Add MFA. The NPS extension for Microsoft Entra multifactor authentication, or a third-party RD Gateway MFA product, adds a second factor to every connection.
- Restrict groups. Keep the CAP and RAP limited to the users and computers that need them.
- Lock out guessing. Set an account lockout policy and watch the TerminalServices-Gateway event log for failed logons.
- Use a real certificate and keep TLS 1.2 or later enabled.
Frequently asked questions
What port does RD Gateway use?
TCP 443 (HTTPS) for clients, plus optional UDP 3391 for UDP transport. The gateway then talks to internal machines on 3389.
Is RD Gateway secure?
It is much safer than exposing port 3389 directly, because traffic is wrapped in TLS and every connection is checked against policies. Add MFA and keep it patched to make it a strong option.
Is RD Gateway the same as a VPN?
No. A VPN puts the client on the internal network. RD Gateway only relays Remote Desktop sessions to the computers the RAP allows, so users never get general network access.
Do I need RD Gateway for a single RDP server?
Not usually. For one server, change the RDP port, require Network Level Authentication, use strong passwords and limit access with the firewall. A gateway pays off when several users reach several internal machines.


