> ## Documentation Index
> Fetch the complete documentation index at: https://docs.serververs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Serververse Transit in LXC Containers

> Configure an unprivileged LXC container on Proxmox VE 9 to run Serververse Transit using userspace WireGuard.

Serververse Transit can run inside an unprivileged Linux Container (LXC) using userspace WireGuard. By default, unprivileged containers do not have access to the TUN device required to establish a WireGuard tunnel.

This guide explains how to configure the container, install the required dependencies, run the Serververse Transit installer, and verify the connection.

This guide is for Proxmox VE 9 or later, with an Ubuntu 24.04 container.

> [!NOTE]
>
> **Routing a subnet to multiple containers?**
>
> You do not need to install a separate Transit tunnel inside every container. Follow the [Hypervisor Setup](https://docs.serververs.com/labs/ip-transit/tunneling-hypervisor#using-lxc-containers) guide to connect your containers to `br-transit`.

## How It Works

LXC containers share the host's Linux kernel. An unprivileged container maps its root user to an unprivileged user on the host, restricting its ability to load kernel modules and access certain devices.

Serververse Transit uses WireGuard for tunneling. Inside an LXC container, it can use `wireguard-go`, a userspace implementation of WireGuard that does not require the WireGuard kernel module.

However, userspace WireGuard still requires access to the TUN device at `/dev/net/tun`. You must pass this device through from the Proxmox host before installing Transit.

## Prerequisites

Before proceeding, ensure that you have:

* A Proxmox VE 9 (or later) host with access to its shell or web interface.
* An unprivileged LXC container running Ubuntu 24.04.
* Root access inside the container.
* An active Serververse Transit tunnel and access to the [Serververse Labs Dashboard](https://labs.serververs.com).

You do not need to enable LXC nesting or convert the container into a privileged container.

## Installation

**1. Create an LXC container**

Create an unprivileged LXC container using the Ubuntu 24.04 template (download it under your storage → CT Templates → Templates if it isn't listed).

Complete the initial setup and ensure that you can access the container through SSH or the Proxmox console.

**2. Pass through the TUN device**

In the Proxmox web interface:

1. Select your container.
2. Open the **Resources** tab.
3. Select **Add** and then **Device Passthrough**.
4. Set the **Device Path** to `/dev/net/tun`.
5. Save the configuration.

If the container is running, perform a full shutdown and start it again. Restarting the operating system from inside the container is not sufficient.

> [!TIP]
>
> Prefer the shell? See [Can I use the Proxmox shell instead of the web interface?](#can-i-use-the-proxmox-shell-instead-of-the-web-interface).

**3. Install the dependencies**

Open a shell inside the container. From the Proxmox host, you can use `pct enter <ct-id>`, replacing `<ct-id>` with the container ID.

Run:

```bash theme={null}
    apt-get update
    apt-get install -y wireguard-go wireguard-tools iptables iproute2 curl
```

**4. Verify the container configuration**

Run the following checks inside the container:

```bash theme={null}
    test -c /dev/net/tun && echo "tun OK"
    command -v wireguard-go >/dev/null && echo "wireguard-go OK"

    iptables -t mangle -N SVTEST &&
      iptables -t mangle -A SVTEST \
        -j CONNMARK --set-xmark 0x64/0xff &&
      echo "connmark OK"

    iptables -t mangle -F SVTEST
    iptables -t mangle -X SVTEST
```

Confirm that the output includes:

* `tun OK`
* `wireguard-go OK`
* `connmark OK`

If the `connmark OK` check fails, follow [Configuring Return-Path Rules](#configuring-return-path-rules) before continuing.

**5. Install Serververse Transit**

1. Sign in to the [Serververse Labs Dashboard](https://labs.serververs.com).
2. Navigate to **Tunnels**.
3. Open your tunnel and select **Generate command**.
4. Copy the generated command and execute it inside the LXC container.

If the WireGuard kernel module is unavailable, the installer may display the following message:

```text theme={null}
    [!] Missing WireGuard kernel module. Falling back to slow userspace implementation.
```

This is expected when using userspace WireGuard inside an LXC container.

`wireguard-go` also prints a boxed notice saying it isn't required because the kernel supports WireGuard. That notice is harmless; the container can't use the host's kernel module, so userspace WireGuard is the right choice here.

**6. Verify DNS resolution**

The installer may install `resolvconf`, which can interfere with the `/etc/resolv.conf` configuration managed by Proxmox.

If domain names stop resolving after installation, remove the package:

```bash theme={null}
    apt-get purge -y resolvconf
```

Restart the container if necessary, then verify that DNS resolution works.

**7. Verify the tunnel**

Run:

```bash theme={null}
    curl -4 --interface <YOUR_ROUTED_IP> ip.me
    sudo sv-transit status
```

Replace `<YOUR_ROUTED_IP>` with the Transit IP from your dashboard. The `curl` command should return that IP, and `sv-transit status` should report a recent handshake.

> [!NOTE]
>
> A plain `curl ip.me` shows your normal internet IP, not your Transit IP. Only traffic sent from the Transit IP goes through the tunnel.

## Configuring Return-Path Rules

Serververse Transit uses `iptables` connection-marking rules (`CONNMARK`) to ensure that replies from Docker containers, port-forwarded services, and other NAT-based workloads return through the tunnel.

These rules require the `xt_connmark` kernel module. An unprivileged LXC container cannot load this module itself.

If the `connmark OK` readiness check fails, choose one of the following approaches.

> [tab] Host access available
>
> **Recommended:** Load the required module on the Proxmox host.
>
> Run the following commands on the host:
>
> ```bash theme={null}
>     modprobe xt_connmark
>     echo xt_connmark > /etc/modules-load.d/sv-transit.conf
> ```
>
> The first command loads the module immediately. The second ensures that it is loaded automatically at boot.
>
> Re-run the `connmark` readiness check inside the container. Once it succeeds, continue with the Transit installer.

> [tab] No host access
>
> If you cannot modify the Proxmox host and do not use Docker, port forwarding, or other NAT-based services inside the container, you can run Transit without the return-path rules.
>
> 1. Run the installer to generate the tunnel configuration.
> 2. If the tunnel fails to start with a `CONNMARK` error, remove the relevant rules from the configuration and start the tunnel.
>
> ```bash theme={null}
>     sed -i '/CONNMARK/d; /fwmark/d' /etc/wireguard/sv-transit.conf
>     systemctl enable --now wg-quick@sv-transit
> ```
>
> > [!WARNING]
> >
> > Without the return-path rules, services exposed through Docker or port forwarding may not be reachable through your Transit IP. Services listening directly inside the container work normally.

## Troubleshooting

> [accordion] RTNETLINK answers: Not supported
>
> This can indicate that userspace WireGuard is unavailable or that the TUN device has not been passed through correctly.
>
> Verify that both `/dev/net/tun` and `wireguard-go` are available:
>
> ```bash theme={null}
>     test -c /dev/net/tun && echo "tun OK"
>     command -v wireguard-go
> ```
>
> If either check fails, correct the configuration before running the installer again.

> [accordion] Couldn't load target CONNMARK
>
> The required `xt_connmark` kernel module may not be loaded on the Proxmox host.
>
> Follow [Configuring Return-Path Rules](#configuring-return-path-rules) to load the module or use the limited configuration described there.

> [accordion] /dev/net/tun is missing
>
> A full container shutdown and start is required after adding the device.
>
> In Proxmox, confirm that `/dev/net/tun` appears in the container's **Resources** tab, then stop and start the container.

> [accordion] Domain names no longer resolve
>
> The `resolvconf` package may have changed how DNS configuration is managed.
>
> Remove it if it is not required:
>
> ```bash theme={null}
>     apt-get purge -y resolvconf
> ```
>
> Restart the container if necessary and test DNS resolution again.

> [accordion] The tunnel starts but services are unreachable
>
> If services are exposed through Docker, NAT, or port forwarding, verify that the return-path rules are configured correctly.
>
> Check the `xt_connmark` module on the host and confirm that the tunnel configuration contains the required connection-marking rules.

## Frequently Asked Questions

### Can I use the Proxmox shell instead of the web interface?

Yes. Run the following command on the Proxmox host, replacing `<ct-id>` with your container ID:

```bash theme={null}
pct set <ct-id> --dev0 /dev/net/tun
```

Shut down the container and start it again to apply the change.

### Can I edit the container config file instead?

Yes. On the Proxmox host, add these lines to `/etc/pve/lxc/<ct-id>.conf`, then shut the container down and start it again:

```text theme={null}
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
```

### Can I use a Debian container?

Package availability varies by Debian release. Check whether `wireguard-go` is available:

```bash theme={null}
apt-cache policy wireguard-go
```

If no package candidate is available, use the Ubuntu 24.04 template instead.

### Is userspace WireGuard slower?

Userspace WireGuard generally consumes more CPU than the kernel implementation and may deliver lower throughput.

If you control the Proxmox host, you can load the kernel WireGuard module:

```bash theme={null}
modprobe wireguard
echo wireguard >> /etc/modules-load.d/sv-transit.conf
```

WireGuard uses the kernel module automatically whenever it's loaded.

### What if my container is hosted by another provider?

Ask your provider to enable access to `/dev/net/tun` for your container. If possible, also ask them to load the `xt_connmark` kernel module.

If the provider cannot enable the required functionality, consider using the [no-host-access configuration](#configuring-return-path-rules) or running Transit in a virtual machine.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.