> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/gateway/guides/connect/agent-tunnel.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Agent tunnel

Route Devolutions Gateway sessions through Devolutions Agent to reach private networks without inbound ports: setup, enrollment, routing and troubleshooting.

The ***Agent tunnel*** lets Devolutions Gateway reach machines on a private network that it cannot connect to directly. Devolutions Agent, installed on a machine inside that network, connects out to Devolutions Gateway and advertises the IP ranges and DNS names it can reach. From then on, sessions that go through the gateway to one of those destinations are routed through the agent automatically: users and entries do not change.

The agent tunnel is an opt-in feature of Devolutions Gateway, turned off by default. It is managed from Devolutions Server, Devolutions Cloud or Remote Desktop Manager.

## How it works

<table><thead><tr><th width="220">PART</th><th>ROLE</th></tr></thead><tbody><tr><td><strong>Devolutions Gateway</strong></td><td>Listens for agents on a UDP port (QUIC, 4433 by default), keeps the list of connected agents and their routes, and picks the agent for each session.</td></tr><tr><td><strong>Devolutions Agent</strong></td><td>Opens one outbound QUIC connection to the gateway, advertises its IPv4 subnets and DNS names, and opens the TCP connections to the destinations on the gateway's behalf.</td></tr><tr><td><strong>Devolutions Server or Devolutions Cloud</strong></td><td>Generates the enrollment strings that let agents join a gateway, shows the agents, and authorizes every session as usual.</td></tr></tbody></table>

* Nothing at the agent site needs a public IP address or an inbound firewall rule, so it works behind NAT.
* The gateway must be reachable by the agents (UDP) and by the users and Devolutions Server or Devolutions Cloud (HTTPS), as usual.
* The agent needs ordinary network access (routing and DNS) to the destinations it advertises: it is the last hop on the private network.
* One gateway can have many agents, and one site can run several agents for redundancy.

## Before you start

* Devolutions Gateway and Devolutions Agent are installed. Devolutions Agent runs on Windows or Linux. The agent tunnel requires Devolutions Gateway 2026.3.0 or later. Agents enrolled with an earlier version of Devolutions Gateway must be enrolled again after the update.
* The agent machine can reach the gateway over HTTPS (the Devolutions Gateway HTTP listener, 7171 by default) to enroll, and over UDP on the agent tunnel port (4433 by default) for the tunnel.
* The gateway firewall allows inbound UDP on the agent tunnel port from the agent sites.
* You can manage the gateway in Devolutions Server or Devolutions Cloud.

## Turn on the agent tunnel on the gateway

{% tabs %}
{% tab title="Windows installer" %}

1. Run the Devolutions Gateway installer and choose to configure Devolutions Gateway now.
2. Select ***Enable Agent Tunnel***.
3. Keep the ***UDP port*** at `4433` or enter another port.
4. Finish the wizard.

For an unattended installation, use the installer properties `P.ENABLEAGENTTUNNEL` and `P.AGENTTUNNELPORT`. The Windows Firewall rules that the installer creates for Devolutions Gateway cover TCP and UDP.
{% endtab %}

{% tab title="PowerShell" %}

```powershell
$AgentTunnel = New-DGatewayAgentTunnelConfig -Enabled -ListenPort 4433
Set-DGatewayConfig -AgentTunnel $AgentTunnel
Restart-DGateway
```

`-ListenPort` accepts 1 to 65535 (default 4433).

{% hint style="warning" %}
When the `DevolutionsGateway` PowerShell module saves `gateway.json`, it keeps only the keys it knows. After a save, check the file and re-add `"TlsVerifyStrict": true` and any other key that was removed. When the `WebApp` section contains a key the module does not know, the module drops the whole `WebApp` section, which turns off the standalone web application: add the section back in `gateway.json`, or run `Set-DGatewayConfig -WebApp (New-DGatewayWebAppConfig -Enabled $true -Authentication Custom)`, then restart the Devolutions Gateway service. See [PowerShell module](https://docs.devolutions.net/gateway/reference/powershell-module.md).
{% endhint %}
{% endtab %}

{% tab title="gateway.json" %}
Edit `gateway.json` (`%ProgramData%\Devolutions\Gateway\` on Windows, `/etc/devolutions-gateway/` on Linux), then restart the Devolutions Gateway service.

```json
{
  "Hostname": "gateway.example.com",
  "AgentTunnel": {
    "Enabled": true,
    "ListenPort": 4433
  }
}
```

On Linux, open the UDP port in the firewall of the gateway machine.
{% endtab %}
{% endtabs %}

`Hostname` is the name agents use to reach the gateway: the gateway gives agents the address `Hostname:ListenPort` at enrollment, and agents check the gateway identity against this name. Set it to the public DNS name of the gateway.

When the agent tunnel is on, Devolutions Gateway stops at startup if it cannot open the UDP port ("failed to bind agent tunnel listener").

## Generate an enrollment string

An enrollment string lets one agent join one gateway. It expires after the lifetime you choose.

{% tabs %}
{% tab title="Devolutions Server" %}

1. Go to ***Administration*** – ***Devolutions Gateway***.
2. Open the menu of the gateway and select ***Agent tunnel***.
3. Click ***Generate enrollment string***.
4. Enter a ***Name*** for the agent (1 to 255 printable ASCII characters).
5. Choose a ***Lifetime***: ***1 Hour*** (default), ***4 Hours***, ***24 Hours*** or ***7 Days***.
6. Click ***Generate***.
7. Copy the ***Enrollment string*** with ***Copy to clipboard***. The dialog also shows the ***QUIC endpoint*** the agent will use and when the string expires (***Expires on***, ***Expires in***).

The ***Agent tunnel*** dialog opens only when the gateway supports the agent tunnel and has it turned on. Otherwise: "Agent Tunnel is not enabled on this Gateway. In gateway.json, set AgentTunnel.Enabled = true and restart the Gateway." or "This Gateway version does not support Agent Tunnel. Upgrade the Gateway to a version that ships the Agent Tunnel API."
{% endtab %}

{% tab title="Devolutions Cloud" %}

1. Go to ***Administration*** – ***Devolutions Gateway***.
2. Open ***More*** on the gateway and select ***Agent tunnel***.
3. Click ***Generate enrollment string***.
4. Enter a ***Name*** and choose a ***Lifetime***: ***1 hour***, ***4 hours***, ***1 day*** or ***7 days***.
5. Generate the string and copy the ***Enrollment string***.

The enrollment string is generated in the browser, which must reach the gateway ("Devolutions Gateway is unreachable. Please make sure it is up and running.").
{% endtab %}

{% tab title="Remote Desktop Manager" %}
With a Devolutions Server workspace:

1. Go to ***Administration*** – ***Privileged access*** – ***Devolutions Gateway***.
2. Select the gateway and open the ***Agent tunnel*** tab of its details.
3. Click ***Generate enrollment string***.
4. Enter a ***Name*** and choose a ***Lifetime*** (1 hour by default, 4 hours, 1 day or 7 days).
5. Copy the ***Enrollment string***.
   {% endtab %}
   {% endtabs %}

{% hint style="warning" %}
The enrollment string is a secret: anyone who has it can enroll an agent in your gateway until it expires. Send it through a secure channel, use the shortest lifetime that works, and generate a new one if it expires before you finish.
{% endhint %}

## Install and enroll the agent

{% tabs %}
{% tab title="Windows installer" %}

1. Run the Devolutions Agent installer on the machine inside the private network.
2. In ***Custom Setup***, select the ***Agent Tunnel*** feature ("Connects the agent to a Devolutions Gateway. Requires an enrollment string from your gateway operator.").
3. On the ***Agent Tunnel*** page, paste the string in ***Enrollment String (provided by your gateway operator)***.
4. In ***Advertise Subnets***, enter the IPv4 ranges this agent should reach, separated by commas, for example `10.10.0.0/24, 192.168.1.0/24`.
5. In ***Advertise DNS Routes***, enter the names this agent should reach, separated by commas. An exact name matches only itself; `*.example.com` matches the subdomains of `example.com`. When the machine belongs to a DNS domain, the installer offers to advertise its subdomains ("The DNS domain {domain} was detected. Advertise its subdomains as {route}?").
6. Finish the wizard.

The installer enrolls the agent, then tests the UDP connection to the gateway. If the test fails, the installation fails, so the firewall can be fixed right away.

{% hint style="info" %}
The installer page says that local subnets are detected automatically when ***Advertise Subnets*** is left blank. Devolutions Agent does not detect subnets: with no subnets, the agent advertises only its DNS routes. Enter the subnets explicitly.
{% endhint %}

For an unattended installation, add `F.Tunnel` to `ADDLOCAL` and set `AGENT_TUNNEL_ENROLLMENT_STRING`, `AGENT_TUNNEL_ADVERTISE_SUBNETS`, `AGENT_TUNNEL_ADVERTISE_DOMAINS` and, to advertise the detected DNS domain, `AGENT_TUNNEL_INCLUDE_DETECTED_DOMAIN=1`. Values typed on a command line are visible to other processes on the machine: run the installation from a protected script or deployment tool. See [Agent tunnel in the Devolutions Agent documentation](https://docs.devolutions.net/agent/guides/agent-tunnel).
{% endtab %}

{% tab title="Command line" %}
On an installed agent (Windows or Linux), enroll from an elevated prompt. With `-`, the command reads the enrollment string from the standard input, so it does not appear on the command line:

```bash
devolutions-agent up --enrollment-string - --advertise-subnets 10.10.0.0/24 --advertise-domains "*.example.com"
```

On Windows, the command is `DevolutionsAgent.exe up …`. Paste the enrollment string when the command waits for input, then restart the Devolutions Agent service. The gateway address comes from the enrollment string; `--gateway <URL>` overrides it.
{% endtab %}
{% endtabs %}

## Confirm the agent is online

Open the ***Agent tunnel*** dialog of the gateway again. The agent shows ***Online***, with its ***Subnets***, ***Domains*** and ***Last seen*** time. An agent is shown ***Offline*** when the gateway has received nothing from it for 90 seconds.

To test the UDP path from the agent machine:

```bash
devolutions-agent probe
```

On Windows: `DevolutionsAgent.exe probe`. It reports "Gateway QUIC endpoint is reachable", or fails with "gateway QUIC endpoint did not respond within …".

To retire an agent, select it in the ***Agent tunnel*** dialog and click ***Delete*** ("Do you want to delete this agent?"), then uninstall the agent or remove its ***Agent Tunnel*** feature.

## Connect through the agent

Nothing changes for users. They open entries through the gateway as usual, and the gateway routes the session through an agent when the destination matches its routes.

1. In the entry, set ***VPN/tunnel/gateway*** to ***Devolutions Gateway*** and pick the gateway the agent enrolled with.
2. Set the host of the entry to the internal destination, for example `10.10.0.20` or `server.example.com`.
3. Open the entry.

### Choose an agent for an entry (Devolutions Cloud)

In the Devolutions Cloud web interface, the ***VPN/tunnel/gateway*** field of an entry has an ***Agent*** setting:

* ***Automatic***: "The gateway picks the agent whose advertised subnets or domains match the destination."
* A specific agent: "Sessions always go through this agent. If it is offline or cannot reach the destination, the session fails instead of taking another route."

Warnings: "This agent is offline. Sessions fail until it reconnects.", "This agent is no longer enrolled on this gateway. Sessions fail until you choose another agent." Choosing an agent is not possible when the gateway is a farm ("Choosing an agent is not supported when the gateway is a farm. Select a gateway that is not part of a farm.") or when the entry uses the default gateway ("Choosing an agent is not supported with the default gateway. Select a specific gateway to choose an agent."). When the chosen agent is enrolled only on the selected gateway, a warning reads "This agent only exists on this gateway. Sessions through an alternate gateway fail."

## How the gateway picks the agent

1. When the session names a specific agent, it goes through that agent or fails. It never falls back to a direct connection or another agent.
2. Otherwise, the gateway compares the destination with the routes of every online agent:
   * an IP address matches the advertised IPv4 subnets;
   * a host name matches an advertised exact name, or a wildcard route such as `*.example.com`. The gateway compares names; it does not resolve them;
   * a subnet match or an exact name match beats a wildcard match, and a longer wildcard beats a shorter one;
   * between equally good matches, the agent whose routes arrived most recently is tried first, then the others.
3. When no route matches, the gateway connects to the destination directly, as without the agent tunnel. When matching agents exist but none can connect, the session fails.

The agent resolves host names with the DNS of its own network. Advertise DNS routes for hosts that exist only in internal DNS, and subnets for hosts addressed by IP. Only IPv4 subnets can be advertised: reach an IPv6-only host through a DNS route.

There is no per-entry option to bypass the agent tunnel. To connect directly, the destination must not match any advertised route, or the matching agents must be offline or removed.

## Security

* The enrollment string is only used to join the gateway. The agent creates its own key pair; the private key never leaves the agent machine.
* The tunnel uses QUIC with mutual TLS: the gateway authenticates the agent by its certificate, and the agent authenticates the gateway. The agent also pins the gateway identity it saw at enrollment.
* The agent refuses connections to anything outside the subnets and DNS routes it advertises.
* Every session still needs a normal authorization from Devolutions Server or Devolutions Cloud. The agent tunnel changes how the gateway reaches the destination, not who may connect.
* The gateway still relays the session, so gateway policies, rulesets and session recording apply.
* Agent certificates are renewed automatically through the tunnel before they expire, as long as the agent keeps connecting.

## Files

* On the gateway, the agent tunnel adds the files `agent-tunnel-ca-cert.pem`, `agent-tunnel-ca-key.pem`, `agent-tunnel-server-cert.pem` and `agent-tunnel-server-key.pem`, and stores enrolled agents in `gateway.db`, in the Devolutions Gateway configuration folder. `agent-tunnel-ca-key.pem` is a private key: keep the folder protected and included in backups. Downgrading Devolutions Gateway to an earlier version can require agents to enroll again.
* On the agent, enrollment writes the certificates in the `certs` folder of the Devolutions Agent data folder (`%ProgramData%\Devolutions\Agent\certs` on Windows) and a `Tunnel` section in `agent.json`.

## Troubleshooting

<table><thead><tr><th width="300">PROBLEM</th><th>CHECK</th></tr></thead><tbody><tr><td><strong>Enrollment fails during installation</strong></td><td>The enrollment string expired or was copied incompletely; the gateway is not reachable over HTTPS from the agent ("Agent tunnel enrollment timed out. Verify your Devolutions Gateway is reachable from this machine."); the agent tunnel is off on the gateway.</td></tr><tr><td><strong>The connection test fails at the end of installation</strong></td><td>"Agent tunnel connectivity probe timed out. The agent can't reach the Devolutions Gateway over UDP/QUIC (port 4433); check that the firewall allows it.": UDP to the gateway is blocked, or the gateway <code>Hostname</code> is wrong.</td></tr><tr><td><strong>The agent is Online but sessions connect directly</strong></td><td>The destination is not inside an advertised subnet or DNS route; the destination is IPv6 (use a DNS route).</td></tr><tr><td><strong>The agent shows Offline</strong></td><td>Restart the Devolutions Agent service on the agent machine and check UDP to the gateway with <code>probe</code>.</td></tr><tr><td><strong>"server SPKI hash does not match pinned value from enrollment"</strong></td><td>The gateway identity changed since enrollment. Enroll the agent again with a new enrollment string.</td></tr><tr><td><strong>Sessions pinned to an agent fail</strong></td><td>The agent is offline, deleted, or cannot reach the destination. Pinned sessions never take another route.</td></tr></tbody></table>

## Next

* [Agent tunnel in the Devolutions Agent documentation](https://docs.devolutions.net/agent/guides/agent-tunnel)
* [Ports and firewall](https://docs.devolutions.net/gateway/reference/ports-and-firewall.md)
* [Use a gateway in Remote Desktop Manager](https://docs.devolutions.net/gateway/guides/connect/remote-desktop-manager.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/gateway/guides/connect/agent-tunnel.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
