Set up an app connector in MagicIP mode

Last validated:
App connectors in MagicIP mode are currently in alpha.

To request access to use app connectors in MagicIP mode, contact your Tailscale account team.

MagicIP mode lets you route traffic to applications through an app connector without advertising a subnet route for each destination IP address. Use it for applications behind a content delivery network (CDN) or domains that resolve to many IP addresses, such as *.amazonaws.com.

Prerequisites

To set up an app connector in MagicIP mode, you need:

  • The Owner, Admin, or Network admin role to edit the tailnet policy file and manage app connector settings in the admin console.
  • A Linux device, already connected to your tailnet, to use as the connector. The device must have internet access. You can use a physical device or a virtual machine (VM). In Step 2, you will enable IPv4 and IPv6 forwarding on this device.
  • The latest unstable Tailscale release on every client and connector. Clients must run Tailscale v1.105.181 or later.
  • A public software as a service (SaaS) or self-hosted application to route traffic to. If you want to restrict access to the connector's public IP addresses, you also need the ability to configure an IP allowlist.

During the alpha, a modified client could request access through a connector to public IP addresses outside the domains in its app definitions. Treat connectors in MagicIP mode as equivalent to exit nodes for security purposes. Use this mode only for public applications, not internal applications.

How it works

MagicIP mode uses two types of devices:

  • A client is a device running an application that connects to a configured domain.
  • A connector is a Linux device that resolves the destination and forwards traffic for that domain.

Classic app connectors advertise subnet routes for destination IP addresses, and DNS responses contain the public IP addresses of those destinations. In MagicIP mode, the client allocates MagicIP addresses that are meaningful only on that device and returns them in DNS responses.

When an application connects to a MagicIP address, the client selects a connector for the app and sends the traffic to it over WireGuard. The connector forwards the traffic to the application's real IP address. This reduces the number of advertised routes and lets clients select connectors for each app.

Address pools

MagicIP mode uses two address pools defined for the tailnet and shared by all app definitions:

PoolPurposeDefault range
IPv4 MagicIPAddresses returned in DNS A records.87.81.192.0/20
IPv6 MagicIPAddresses returned in DNS AAAA records.2606:b740:0:c025::/64

All clients use the same address ranges, but each client allocates addresses independently. The same MagicIP address can represent different destinations on different clients. MagicIP addresses aren't visible outside the device.

Get started

To use MagicIP mode, define an app and grant access to it in your tailnet policy file, configure a Linux device as its connector, and verify connectivity from a client.

Step 1. Configure the tailnet policy file

Open the Access controls page of the admin console to edit your tailnet policy file. The examples use tag:connector for the connector and group:app-users for users who can access the app. Before adding the app definition, create the tag and define the group, or replace them with an existing tag and group. Make sure your account can assign the connector tag.

Define an app

MagicIP mode is the next generation of app connectors. During the alpha, the policy syntax and capability name are subject to change.

Add an app definition to the nodeAttrs section under the tailscale.com/app-connectors capability. Set mode to magicip:

{
  "nodeAttrs": [
    {
      "target": ["*"],
      "app": {
        "tailscale.com/app-connectors": [
          {
            "name": "example-app",
            "connectors": ["tag:connector"],
            "domains": ["*.example.com"],
            "mode": "magicip",
          },
        ],
      },
    },
  ],
  // Other tailnet policy options
}
FieldDescription
nameA unique, lowercase app name, displayed in the admin console and referenced by grants.
connectorsOne or more tags identifying the connector devices that serve the app's domains.
domainsDomains to route through the connector. Wildcards are supported for subdomains, such as *.example.com, but not for top-level domains, such as *.com.
modeSet to magicip for MagicIP mode. The default, subnet, uses classic app connector behavior. You can use different modes for different apps in the same tailnet.

During the alpha, target must be ["*"]. This includes the tagged connectors and the users who might use the app. App definitions apply across the tailnet, but your access control policies must make the app's connectors visible to clients. If a connector isn't visible to a client, DNS requests for the app's domains fail.

Grant access to the app

Add a grant for the users or devices that need access. Use appc:<app-name> as the destination, where <app-name> matches the app definition's name field. For example-app, the destination is appc:example-app:

{
  "grants": [
    {
      "src": ["group:app-users"],
      "dst": ["appc:example-app"],
      "ip": ["*"],
    },
  ],
  // Other tailnet policy options
}

Grants apply to each app independently, so you can give different groups access to different apps. During the alpha, autogroup:internet doesn't automatically match app destinations. Add an explicit grant for each app.

Combined policy example

The following example combines the app definition and grant. Merge these entries into your existing policy file, keeping your group and tag definitions and other policy settings.

{
  "nodeAttrs": [
    {
      "target": ["*"],
      "app": {
        "tailscale.com/app-connectors": [
          {
            "name": "example-app",
            "connectors": ["tag:connector"],
            "domains": ["*.example.com"],
            "mode": "magicip",
          },
        ],
      },
    },
  ],

  "grants": [
    {
      "src": ["group:app-users"],
      "dst": ["appc:example-app"],
      "ip": ["*"],
    },
  ],
  // Other tailnet policy options
}

Step 2. Configure a device as a connector

A connector in MagicIP mode runs the standard Tailscale daemon, tailscaled. You don't need to install an additional binary.

  1. On the Linux connector, enable IPv4 and IPv6 forwarding:

    sudo sysctl -w net.ipv4.ip_forward=1
    
    sudo sysctl -w net.ipv6.conf.all.forwarding=1
    

    Make the settings persistent so they survive a restart. For example, add the following to /etc/sysctl.d/99-tailscale.conf:

    net.ipv4.ip_forward = 1
    net.ipv6.conf.all.forwarding = 1
    
  2. Run Tailscale as a connector with the tag from your app definition:

    sudo tailscale up --advertise-connector --advertise-tags=tag:connector
    

    The --advertise-connector flag lets the device route traffic for app domains in the policy file. The --advertise-tags flag authenticates the device with the specified tag.

  3. (Optional) To prevent users from accessing the application without the connector, restrict application access to the connector's public IP addresses.

Step 3. Verify connectivity

Run the following checks on a client that has access to the app. Replace app.example.com with a domain covered by your app definition. The example outputs use the default IPv4 MagicIP pool.

  1. Query the Quad100 DNS resolver. The response should contain MagicIP addresses:

    dig @100.100.100.100 +short app.example.com
    

    Example output:

    87.81.192.0
    87.81.192.1
    
  2. Test connectivity using the application or ping. The ping command should show a MagicIP address. The destination must respond to ping for you to receive replies.

    ping app.example.com
    

    Example output:

    PING app.example.com (87.81.192.0) 56(84) bytes of data.
    

    The tailscale ping command doesn't currently support MagicIP destinations.

  3. On a Linux client, check that the Tailscale routing table contains a route for the MagicIP range:

    ip route show table 52 | grep -F 87.81.192.0/20
    

    Example output:

    87.81.192.0/20 dev tailscale0
    

If the client's DNS responses and routes are correct but connections fail, check the connector using the troubleshooting steps.

Add, update, or remove an app

You can manage apps directly in the tailnet policy file:

  • To add an app, add an entry under tailscale.com/app-connectors with a unique name, connector tags, domains, and "mode": "magicip". Then grant access to the app.
  • To update an app, edit its domains or connectors.
  • To remove an app, delete its definition and grants. Traffic to those domains then flows directly from the client, or through an exit node if the client uses one.

Troubleshooting

SymptomWhat to check
DNS lookups fail for an app domain.Verify that the client runs the latest unstable Tailscale release, at least v1.105.181. Query the domain with dig @100.100.100.100 <domain>. Run tailscale debug localapi v0/conn25/state to check whether the client's MagicIP pool is exhausted and whether the app's connectors are visible to the client.
DNS works, but connections fail.Run tailscale debug localapi v0/conn25/state to check the client's route for the MagicIP range, connector health, and address pool usage.
Client DNS responses and routes are correct, but connections fail.Check the connector's tailscaled logs. On a Linux connector that uses systemd, run sudo journalctl -fu tailscaled.

tailscale debug localapi v0/conn25/state is a debugging endpoint that may change in the future. While it is safe to use for troubleshooting, you should not depend on this endpoint for automation.

Turn off MagicIP mode

To disable MagicIP mode entirely, remove all app connectors running in MagicIP mode from your tailnet. Then, contact your Tailscale Solutions Engineer or Customer Success Engineer to disable the feature flag for your tailnet and restore direct routing or classic app connector routing for the affected domains.

Limitations

The following limitations apply during the alpha:

  • MagicIP mode supports public applications only. Modified clients can request access to public IP addresses outside the domains in an app definition, so treat connectors as equivalent to exit nodes for security purposes.
  • High availability (HA), geographic routing with MagicRoute, and regional routing aren't supported.
  • Every client that uses a MagicIP app must run the latest unstable Tailscale release. Keep classic app connectors available for clients running earlier versions until all clients are upgraded.
  • The tailscale ping command doesn't support MagicIP destinations. Use ping or the application to test connectivity.
  • DNS rewriting removes DNS Security Extensions (DNSSEC) records and flattens CNAME references. Responses contain A or AAAA records directly for the queried fully qualified domain name (FQDN).
  • MagicIP mode doesn't translate between IP versions. IPv4 traffic stays IPv4, and IPv6 traffic stays IPv6.
  • If a client's MagicIP pool is exhausted, DNS lookups fail or new connections to new destinations are dropped until addresses become available.
  • A connector serving an app doesn't forward that app's traffic to other connectors. Each client connects directly to its selected connector.
  • Connectors must run Linux. Clients can use any supported operating system with the required Tailscale version.
  • Routing traffic from devices on a shared subnet through a connector isn't supported.

Feedback

To report issues or share feedback about MagicIP mode, contact Tailscale Support or your Customer Success Engineer.