# TCP

A TCP connection resource is unique in that the content of the TCP traffic is not recorded in our logs, only the traffic metadata (who accessed the resource, when, and how many bytes were transmitted and received). This behavior is different from what you experience with other StrongDM resources that support logging and auditing of actions taken by a user. Logs of TCP traffic are located in the [Queries](https://app.strongdm.com/app/queries) page in the Admin UI and are recorded after the close of the session.

The TCP connection resource may be used for a variety of types of resources that accept TCP connections, but are not currently supported by StrongDM. It provides the ability to use StrongDM to connect to unsupported resources, and have at least partial auditing support for them.

The TCP connection resource is not a valid way to connect to resource types that are distributed across more than one server (such as Kafka).

{% hint style="info" %}
The TCP connection resource supports TLS connections only if you are able to disable hostname verification or allow invalid hostnames on the client side when attempting to connect to the resource through StrongDM. It also does not support resources which require connections over multiple ports at the same time.
{% endhint %}

## Limitations

* StrongDM records metadata only (who, when, bytes in/out) for TCP resources. Payload/commands are not logged.
* TLS works only if the client can disable hostname verification or allow invalid hostnames when connecting via StrongDM.
* It is single-port only, meaning it's not suitable for protocols requiring multiple concurrent ports or distributed brokers (for example, Kafka).
* Credentials are not stored. The TCP resource itself does not hold usernames and passwords; your client supplies any needed credentials at the time of connection.

## Prerequisites

* A StrongDM node (gateway, relay, or proxy worker) must be able to reach the target host on the specified port.
* The target service is listening on a single TCP port and behaves correctly through a TCP proxy.
* If using TLS, your client can relax hostname verification or accept non-matching hostnames.
* (Recommended) Decide whether users will connect via Loopback Mode or [Virtual Networking Mode](https://docs.strongdm.com/admin/clients/client-networking/virtual-networking-mode); this affects bind IP/DNS and port override choices.

## Add the Resource in StrongDM

Next, add the resource in StrongDM. This section provides instructions for adding the resource in either the StrongDM Admin UI, CLI, Terraform provider, or SDKs.

{% tabs %}
{% tab title="Admin UI" %}
**Set up and Manage With the Admin UI**

If using the Admin UI to add the resource to StrongDM, use the following steps.

1. Log in to the StrongDM Admin UI and go to **Resources** > **Managed Resources**.
2. Click **Add Resource**.
3. Select **TCP** as the **Resource Type** and set other [resource properties](#resource-properties) to configure how the StrongDM relay connects to the server.
4. Click **create** to save the resource.
5. Click the resource name to view status, diagnostic information, and setting details. After the server is created, the Admin UI displays that resource as unhealthy until the health checks run successfully. When the resource is ready, the **Health** icon indicates a positive, green status.
   {% endtab %}

{% tab title="CLI" %}
**Set up and Manage With the CLI**

This section provides general steps on how to configure and manage the resource using the StrongDM CLI. For more information and examples, please see the [CLI Reference](https://docs.strongdm.com/references/cli) documentation.

1. In your terminal or Command Prompt, log in to StrongDM:

   ```sh
   sdm login
   ```
2. Run `sdm admin servers add rawtcp --help` to view the help text for the command, which shows you how to use the command and what options (properties) are available. Note which [properties](#resource-properties) are required and collect the values for them.

   ```sh
   NAME:
      sdm admin servers add rawtcp - create TCP server

   USAGE:
      sdm admin servers add rawtcp [command options] <name>

   OPTIONS:
      --bind-interface value                     IP address on which to listen for connections to this resource on clients. Specify "default", "loopback", or "vnm" to automatically allocate an available address from the corresponding IP range configured in the organization. (default: "default")
      --egress-filter value                      apply filter to select egress nodes e.g. 'field:name tag:key=value ...'
      --hostname value                           The traffic content is not recorded. (required)
      --port value                               (default: 49150)
      --port-override value                      Port on which to listen for connections to this resource on clients. Specify "-1" to automatically allocate an available port. (default: -1)
      --proxy-cluster-id value                   proxy cluster id
      --subdomain value, --bind-subdomain value  DNS subdomain through which this resource may be accessed on clients (e.g. "app-prod" allows the resource to be accessed as "app-prod.<your-org-name>.<sdm-proxy-domain>"). Only applicable to HTTP-based resources or resources using virtual networking mode.
      --tags value                               tags e.g. 'key=value,...'
      --template, -t                             display a JSON template
      --timeout value                            set time limit for command
   ```
3. Run `sdm admin servers add rawtcp <RESOURCE_NAME>` to add the resource in StrongDM. Set all required properties with their values. For example:

   ```sh
   sdm admin servers add rawtcp "tcp-generic-prod-01"
     --hostname "tcp01.acme.internal"
     --port 12345
     --bind-interface "default"
     --port-override -1
     --egress-filter 'field:name tag:env=prod tag:region=us-west'
     --proxy-cluster-id "plc_0123456789abcdef"
     --secret-store-id "ss_abcdef0123456789"
     --subdomain "tcp-prod01"
     --tags "env=prod,protocol=custom,team=infra"
     --timeout 30
   ```
4. Check that the resource has been added. The output of the following command should show the resource's name:

   ```sh
   sdm admin resources list
   ```

{% endtab %}

{% tab title="Terraform" %}
**Set up and Manage With Terraform**

This section provides an example of how to configure and manage the resource using the Terraform provider. For more information and examples, please see the [Terraform provider](https://github.com/strongdm/terraform-provider-sdm) documentation.

```
# Install StrongDM provider
terraform {
  required_providers {
    sdm = {
      source  = "strongdm/sdm"
      version = "16.5.0"
    }
  }
}

# Configure StrongDM provider
provider "sdm" {
  # Add API access key and secret key from the Admin UI
  api_access_key = "njjSn...5hM"
  api_secret_key = "ziG...="
}

# Create TCP server
resource "sdm_resource" "tcp_generic_prod_01" {
  rawtcp {
    # Required
    name     = "tcp-generic-prod-01"         # <name>
    hostname = "tcp01.acme.internal"         # --hostname
    port     = 12345                          # --port (default 49150 if omitted)

    # Common networking options
    bind_interface = "default"                # --bind-interface ("default" | "loopback" | "vnm")
    port_override  = -1                       # --port-override (-1 = auto-allocate)
    egress_filter  = "field:name tag:env=prod tag:region=us-west"  # --egress-filter
    subdomain      = "tcp-prod01"             # --subdomain (VN/HTTP-only applicability noted in CLI)

    # Optional integrations
    proxy_cluster_id = "plc_0123456789abcdef" # --proxy-cluster-id
    secret_store_id  = "ss_abcdef0123456789"  # --secret-store-id

    # Tags
    tags = {                                  # --tags
      env      = "prod"
      protocol = "custom"
      team     = "infra"
    }
  }
}
```

{% endtab %}

{% tab title="SDKs" %}
**Set up and Manage With SDKs**

In addition to the Admin UI, CLI, and Terraform, you may configure and manage your resource with any of the following SDK options: Go, Java, Python, and Ruby. Please see the following references for more information and examples.

| Go            | ​[pkg.go.dev](https://pkg.go.dev/github.com/strongdm/strongdm-sdk-go/v16)​ | ​[strongdm-sdk-go](https://github.com/strongdm/strongdm-sdk-go)​         | ​[Go SDK Examples](https://github.com/strongdm/strongdm-sdk-go-examples)​         |
| ------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| Java          | ​[javadoc](https://strongdm.github.io/strongdm-sdk-java-docs/)​            | ​[strongdm-sdk-java](https://github.com/strongdm/strongdm-sdk-java)​     | ​[Java SDK Examples](https://github.com/strongdm/strongdm-sdk-java-examples)​     |
| Python        | ​[pdocs](https://strongdm.github.io/strongdm-sdk-python-docs/)​            | ​[strongdm-sdk-python](https://github.com/strongdm/strongdm-sdk-python)​ | ​[Python SDK Examples](https://github.com/strongdm/strongdm-sdk-python-examples)​ |
| Ruby          | ​[RubyDoc](https://www.rubydoc.info/gems/strongdm)​                        | ​[strongdm-sdk-ruby](https://github.com/strongdm/strongdm-sdk-ruby)​     | ​[Ruby SDK Examples](https://github.com/strongdm/strongdm-sdk-ruby-examples)​     |
| {% endtab %}  |                                                                            |                                                                          |                                                                                   |
| {% endtabs %} |                                                                            |                                                                          |                                                                                   |

## Resource properties

The following table describes the settings available for your TCP resource.

{% hint style="info" %}
The TCP Connection settings do not include stored credentials. Any credentials your connection requires need to be provided while connecting with the client.
{% endhint %}

<table><thead><tr><th width="199.92333984375">Property</th><th width="129.5078125">Requirement</th><th>Description</th></tr></thead><tbody><tr><td><strong>Display Name</strong></td><td>Required</td><td>Meaningful name to display the resource throughout StrongDM; exclude special characters like quotes (") or angle brackets (&#x3C; or >)</td></tr><tr><td><strong>Server Type</strong></td><td>Required</td><td><strong>TCP</strong></td></tr><tr><td><strong>Proxy Cluster</strong></td><td>Required</td><td>Defaults to "None (use gateways)"; if using <a href="../../networking/proxy-clusters">proxy clusters</a>, select the appropriate cluster to proxy traffic to this resource</td></tr><tr><td><strong>Hostname</strong></td><td>Optional</td><td>The IP/DNS address used to connect to the resource from your gateway or relay, such as <code>windows-server.strongdm.com</code></td></tr><tr><td><strong>Port</strong></td><td>Optional</td><td>Port to connect to the resource; default port value <strong>49150</strong></td></tr><tr><td><strong>Connectivity Mode</strong></td><td>Required</td><td>Select either <strong>Virtual Networking Mode</strong>, which lets users connect to the resource with a software-defined, IP-based network; or <strong>Loopback Mode</strong>, which allows users to connect to the resource using the local loopback adapter in their operating system; this field is shown if <a href="../../clients/client-networking/virtual-networking-mode">Virtual Networking Mode</a> enabled for your organization</td></tr><tr><td><strong>IP Address</strong></td><td>Optional</td><td>If <strong>Virtual Networking Mode</strong> is the selected connectivity mode, an IP address value in the configured Virtual Networking Mode subnet in the organization network settings; if <strong>Loopback Mode</strong> is the selected connectivity mode, an IP address value in the configured Loopback IP range in the organization network settings (by default, <code>127.0.0.1</code>); if not specified, an available IP address in the configured IP address space for the selected connectivity mode will be automatically assigned; this field is shown if <a href="../../clients/client-networking/virtual-networking-mode">Virtual Networking Mode</a> and/or <a href="../../clients/client-networking/loopback-ip-ranges">multi-loopback mode</a> is enabled for your organization</td></tr><tr><td><strong>Port Override</strong></td><td>Optional</td><td>If <strong>Virtual Networking Mode</strong> is the selected connectivity mode, a port value between 1 and 65535 that is not already in use by another resource with the same IP address; if <strong>Loopback Mode</strong> is the selected connectivity mode, a port value between 1024 to 64999 that is not already in use by another resource with the same IP address; when left empty with Virtual Networking Mode, the system assigns the default port to this resource; when left empty for Loopback Mode, an available port that is not already in use by another resource is assigned; preferred port also can be modified later from the <a href="../port-overrides">Port Overrides settings</a></td></tr><tr><td><strong>DNS</strong></td><td>Optional</td><td>If Virtual Networking Mode is the selected connectivity mode, a unique hostname alias for this resource; when set, causes the desktop app to display this resource's human-readable DNS name (for example, <code>k8s.my-organization-name</code>) instead of the bind address that includes IP address and port (for example, <code>100.64.100.100:5432</code>)</td></tr><tr><td><strong>Resource Tags</strong></td><td>Optional</td><td>Resource <a data-mention href="https://app.gitbook.com/s/4XOJmXFslCMVCzIG2rKp/cli/tags">Tags</a> consisting of key-value pairs <code>&#x3C;KEY>=&#x3C;VALUE></code> (for example, <code>env=dev</code>)</td></tr></tbody></table>

## Test the Connection

1. In the Admin UI, view the new TCP resource and notice its health status. It turns green when StrongDM can reach the host/port.
2. Connect using the StrongDM desktop app or CLI to the bind address.
3. If your service uses TLS with strict hostname verification, configure your client to allow mismatched hostnames or disable verification when connecting through StrongDM.
4. If the resource remains unhealthy or the client fails to connect:
   * Verify the hostname/port and network path from the node.
   * Confirm the service listens on a single TCP port and doesn’t require side-channels.
   * Check firewall rules/ACLs.
   * Re-test with a simple TCP client (for example, `nc`, `openssl s_client`) through the StrongDM bind address.
5. Review Queries in the Admin UI after the session ends for metadata (who, when, bytes). Content is not recorded.

If you encounter issues, please consult the [StrongDM Help Center](https://help.strongdm.com/hc/en-us).
