Connecting through Tailscale
Tailscale is a managed virtual private network (VPN). It creates a private mesh network called a tailnet.
Each device on the Tailscale network receives a stable private IP address, and can communicate directly with other devices on the tailnet, without the need to open ports to the public internet or to configure VPN gateways.
Tonic Structural can join your corporate tailnet as a node. It can then reach database servers that are on the same tailnet, even if those servers are in a private network and have no public IP address.
Overview of the steps to enable the connection
To allow Tonic Structural to reach a database through Tailscale, you:
Add your database server to the tailnet - Install the Tailscale agent on the server, or configure a subnet router.
Declare an access control list (ACL) tag - Register the tag in the tailnet policy that Structural uses to identify itself.
Create an OAuth credential - Generate the client secret that Structural uses to authenticate to your tailnet.
Configure the Structural workspace - Enable the Tailscale tunnel and provide the connection details.
Allowing connections to the database server from the tailnet
Connections from Structural arrive at the server's Tailscale IP address, not the server's actual IP address.
You must configure your database server to allow connections from your tailnet's IP address range.
By default, the range is 100.64.0.0/10, although it can be customized.
For a PostgreSQL database server, you add an entry for the subnet in pg_hba.conf.
Adding your database server to the tailnet
To make your database server reachable through Tailscale, you can either:
Install Tailscale directly on the database server.
Use a subnet router.
Installing Tailscale directly on the database server
If you have shell access to the database server, then this is the simplest approach.
Install Tailscale on the server. For platform-specific instructions, go to tailscale.com/download.
If a browser is available:
Run
sudo tailscale up. This returns a link that looks like:Open the URL in a browser. Tailscale prompts for authentication and then adds the server to your tailnet.
For headless servers where no browser is available, use the
--auth-keyflag instead:To generate an auth key, go to
https://login.tailscale.com/admin/settings/keys.Click Generate auth key, then indicate whether the key is:
A one-off key - single use, for a single server.
A reusable key - for multiple servers.
The generated key starts with
tskey-.After you generate the key, run:
Retrieve the server's Tailscale IP address:
Verify that the device appears at
https://login.tailscale.com/admin/machines.
The server now has a stable Tailscale IP address, which is by default in the 100.x.x.x range.
You use the Tailscale IP address as the value of Server in the workspace data connection settings.
Using a subnet router
If you cannot install Tailscale on the database server itself, for example because it is a managed database service, you can instead:
Install Tailscale on any other machine that is on the same private network as the database server.
Configure the machine as a subnet router.
A subnet router advertises a CIDR range to your tailnet. Other nodes such as Structural can then use regular IP addresses to reach the devices on that subnet. Tailscale does not need to be installed on those devices.
To configure a subnet router:
Install Tailscale on a machine that can reach the database server.
Start Tailscale with the
--advertise-routesflag, which specifies the subnet that your database is on:Approve the advertised route:
Go to
https://login.tailscale.com/admin/machines.Click the machine.
Click Edit route settings.
Enable the route.
When you use a subnet router, then in Structural, you set the value of Server to the database server's regular private IP address - for example, 10.0.1.50 - instead of a Tailscale IP address.
Declaring an ACL tag
Tailscale uses ACL tags to control the devices that a given credential can authenticate to.
Before you create an OAuth credential, you must declare the tag that you intend to use in your tailnet's ACL policy.
Go to
https://login.tailscale.com/admin/acls.Edit the policy JSON.
If the policy does not already contain a
tagOwnerssection, then add the section.Add the tag to
tagOwners. For example, to create a tag calledtag:tonic:
Save the policy.
Creating an OAuth credential
Structural authenticates to your tailnet using an OAuth client credential. You create this from the Tailscale admin console under Trust credentials.
Go to
https://login.tailscale.com/admin/settings/trust-credentials.Click + Credential.
Select OAuth as the credential type.

Add a description, then click Next.
To set the credential scope:
From the Scopes dropdown, select Custom scopes.
Under Keys, for Auth Keys, check the Write checkbox.
In the Tags field, provide the ACL tag that you created.
Click Generate credential. Tailscale displays the Credential created panel with the client ID and the client secret.

Copy the Client secret immediately. It is only shown once. The client secret starts with
tskey-client-. In the Structural workspace configuration, you paste this value into the Tailscale Auth Key field. Structural does not use the client ID.
Configuring a workspace to use Tailscale tunneling
After you complete the setup in Tailscale, you can configure a Structural workspace to connect through Tailscale.
Setting the database connection server value
When you connect through Tailscale, in the database connection fields, to set the value of Server:
If you installed Tailscale on the database server, set Server to the Tailscale IP address, which is the stable address that is assigned to the device on your tailnet. By default, the address in the
100.x.x.xrange.If you use a subnet router, then in Structural, set Server to the database server's regular private IP address - for example,
10.0.1.50.
Enabling and configuring the Tailscale connection
To enable and configure the Tailscale connection:
If the connector supports multiple tunneling options:
Toggle Enable Connection Tunnel to the on position.
From the Tunnel type dropdown list, select Tailscale Tunnel.
If the data connector only supports Tailscale tunneling, then it is selected automatically.
In the Tags field, provide a comma-separated list of ACL tags to use to join the tailnet. For example,
tag:tonic-worker. Each tag name must exactly match the tag name that you configured in Tailscale, and must include thetag:prefix. If the tags don't match, then when Structural tries to connect, Tailscale returns an authentication error.Optionally, in the Control Server URL field, provide the URL. This is intended for customers who use Headscale or a self-hosted Tailscale control plane.
In the Tailscale Auth Key field, you can either:
Provide the Tailscale OAuth client credential (value starting with
tskey-client-) that you generated and copied from Tailscale. Structural does not support other types of Tailscale keys, such as user auth keys.If secrets managers are available, select a secret name from a secrets manager.
How the connection works
When Structural uses Tailscale tunneling to establish a connection:
Structural uses the provided credential (OAuth credential or secrets manager secret) to authenticate as a new ephemeral node on your tailnet.
The node is tagged with the specified ACL tags. The tags control what the node can reach based on your tailnet policy.
Structural uses its Tailscale IP address to connect to the database server. Traffic flows through the encrypted tailnet mesh, not the public internet.
When the connection is torn down, the ephemeral node is removed from your tailnet.
Troubleshooting the connection
Here are some errors that might occur during the connection:
Tailscale authentication failed
Either:
The tag in the Tags field does not match the tag on the OAuth credential's
auth_keysscope.The tag is not declared in
tagOwnersin your ACL policy.
Connection times out
Either:
The database server is not on the tailnet.
The ACL policy does not permit the tagged node to reach it.
Invalid auth key type
You used a user auth key or a pre-auth key instead of an OAuth client secret.
Last updated
Was this helpful?