[GH-ISSUE #3297] [Bug] AmneziaWG 2 Docker container has IPv4 forwarding disabled after automatic installation in Proxmox LXC #3164

Open
opened 2026-10-25 04:14:48 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @samwathegreat on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3297

Title: [Bug] AmneziaWG 2 Docker container has IPv4 forwarding disabled after automatic installation in Proxmox LXC

Environment

  • Host: Proxmox VE
  • Guest: Debian 13, unprivileged LXC with nesting enabled
  • VPN: AmneziaWG 2, installed automatically using the official Amnezia Android app
  • Docker: 26.1.5+dfsg1 (installed by Amnezia)
  • Also reproduced with preinstalled Docker 29.8.0
  • /dev/net/tun passed through from Proxmox into LXC
  • Container: amnezia-awg2

Problem

The official Android app successfully installs AmneziaWG 2. The client establishes a VPN connection and completes the handshake, but neither internet nor LAN traffic works.

The VPN interface, UDP listener, NAT rules, and firewall rules are present.

The underlying problem is that IPv4 forwarding is disabled inside the AmneziaWG Docker container, despite being enabled in the parent LXC.

Steps to reproduce

  1. Create a fresh Debian 13 unprivileged Proxmox LXC with Docker nesting and TUN passthrough.

  2. Install AmneziaWG 2 using the official Android app, allowing it to install Docker.

  3. Connect from Android.

  4. Observe a successful handshake but no internet or LAN connectivity.

  5. Run:

    docker exec amnezia-awg2 sysctl net.ipv4.ip_forward

    Result: net.ipv4.ip_forward = 0

  6. Enable forwarding:

    docker exec amnezia-awg2 sysctl -w net.ipv4.ip_forward=1

  7. Internet and LAN connectivity immediately work, without restarting the VPN.

Investigation

  • Parent LXC: net.ipv4.ip_forward = 1
  • Amnezia Docker container: net.ipv4.ip_forward = 0
  • Container NAT and FORWARD rules are configured correctly.
  • The generated /opt/amnezia/start.sh configures the tunnel, iptables and MASQUERADE rules but does not enable IPv4 forwarding.
  • Docker inspect shows only net.ipv4.conf.all.src_valid_mark=1 under HostConfig.Sysctls.
  • A fresh Docker container also defaults to forwarding disabled.
  • Reproduced with two Docker versions and a completely fresh LXC installation.
  • A separate installation in a full Debian VM works without manual intervention.

Expected behavior

The official installer should explicitly enable IPv4 forwarding inside the VPN container, regardless of the default networking behavior of Docker or the host environment.

Suggested fix

Include net.ipv4.ip_forward=1 in the Docker container's sysctl configuration alongside net.ipv4.conf.all.src_valid_mark=1.

Alternatively, ensure forwarding is enabled during the VPN container's initialization.

This should allow the Android app to manage installation, restarts, and updates without manual intervention.

Impact

The installer reports success, and the VPN handshake succeeds, but all routed traffic fails. This is difficult to diagnose because the Docker container appears healthy and the client appears connected.

Originally created by @samwathegreat on GitHub (Oct 18, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3297 **Title: [Bug] AmneziaWG 2 Docker container has IPv4 forwarding disabled after automatic installation in Proxmox LXC** ### Environment - Host: Proxmox VE - Guest: Debian 13, unprivileged LXC with nesting enabled - VPN: AmneziaWG 2, installed automatically using the official Amnezia Android app - Docker: 26.1.5+dfsg1 (installed by Amnezia) - Also reproduced with preinstalled Docker 29.8.0 - `/dev/net/tun` passed through from Proxmox into LXC - Container: `amnezia-awg2` ### Problem The official Android app successfully installs AmneziaWG 2. The client establishes a VPN connection and completes the handshake, but neither internet nor LAN traffic works. The VPN interface, UDP listener, NAT rules, and firewall rules are present. The underlying problem is that IPv4 forwarding is disabled **inside the AmneziaWG Docker container**, despite being enabled in the parent LXC. ### Steps to reproduce 1. Create a fresh Debian 13 unprivileged Proxmox LXC with Docker nesting and TUN passthrough. 2. Install AmneziaWG 2 using the official Android app, allowing it to install Docker. 3. Connect from Android. 4. Observe a successful handshake but no internet or LAN connectivity. 5. Run: `docker exec amnezia-awg2 sysctl net.ipv4.ip_forward` Result: `net.ipv4.ip_forward = 0` 6. Enable forwarding: `docker exec amnezia-awg2 sysctl -w net.ipv4.ip_forward=1` 7. Internet and LAN connectivity immediately work, without restarting the VPN. ### Investigation - Parent LXC: `net.ipv4.ip_forward = 1` - Amnezia Docker container: `net.ipv4.ip_forward = 0` - Container NAT and FORWARD rules are configured correctly. - The generated `/opt/amnezia/start.sh` configures the tunnel, iptables and MASQUERADE rules but does not enable IPv4 forwarding. - Docker inspect shows only `net.ipv4.conf.all.src_valid_mark=1` under `HostConfig.Sysctls`. - A fresh Docker container also defaults to forwarding disabled. - Reproduced with two Docker versions and a completely fresh LXC installation. - A separate installation in a full Debian VM works without manual intervention. ### Expected behavior The official installer should explicitly enable IPv4 forwarding inside the VPN container, regardless of the default networking behavior of Docker or the host environment. ### Suggested fix Include `net.ipv4.ip_forward=1` in the Docker container's sysctl configuration alongside `net.ipv4.conf.all.src_valid_mark=1`. Alternatively, ensure forwarding is enabled during the VPN container's initialization. This should allow the Android app to manage installation, restarts, and updates without manual intervention. ### Impact The installer reports success, and the VPN handshake succeeds, but all routed traffic fails. This is difficult to diagnose because the Docker container appears healthy and the client appears connected.
Author
Owner

@samwathegreat commented on GitHub (Oct 18, 2026):

Further investigation identified why AmneziaWG 2 fails to route traffic when installed through the official Android app inside an unprivileged Proxmox LXC.

Root Cause

  1. The AmneziaWG 2 Dockerfile configures numerous networking parameters in /etc/sysctl.conf, but does not include net.ipv4.ip_forward=1.

  2. The Dockerfile initially creates a placeholder /opt/amnezia/start.sh, which the official Android app subsequently replaces with a generated startup script.

  3. The generated startup script successfully initializes the awg0 interface and configures iptables FORWARD and MASQUERADE rules, but never enables IPv4 forwarding.

  4. Docker creates the container with only the following explicit sysctl setting:

    net.ipv4.conf.all.src_valid_mark=1

  5. IPv4 forwarding is enabled in the parent LXC (net.ipv4.ip_forward=1), but disabled inside the AmneziaWG Docker container (net.ipv4.ip_forward=0).

  6. The problem was reproduced on two installations:

    • Existing unprivileged Proxmox LXC with Docker 29.8.0.
    • Completely fresh Debian 13 unprivileged Proxmox LXC, allowing Amnezia to install Docker 26.1.5 itself.

A separate installation in a full Debian VM works without modification.

Verified Workaround

Adding the following line immediately after #!/bin/bash in /opt/amnezia/start.sh resolves the routing failure:

sysctl -w net.ipv4.ip_forward=1

This can be applied from the LXC using a single command:

docker exec amnezia-awg2 sh -c 'grep -q "^sysctl -w net.ipv4.ip_forward=1$" /opt/amnezia/start.sh || sed -i "2i sysctl -w net.ipv4.ip_forward=1" /opt/amnezia/start.sh'

After enabling forwarding, both internet and LAN connectivity work immediately through the VPN.

Reboot test: PASSED.

The modified startup script survives a normal LXC reboot and automatically enables forwarding when the AmneziaWG container starts.

No Docker image rebuild, Docker downgrade, or additional networking changes were required.

The preferred solution is to explicitly configure IPv4 forwarding when Amnezia creates the Docker container, alongside the existing src_valid_mark setting:

sysctls:
  net.ipv4.conf.all.src_valid_mark: "1"
  net.ipv4.ip_forward: "1"

Alternatively, the Amnezia app could include the following command in its generated startup script:

sysctl -w net.ipv4.ip_forward=1

The startup-script approach has been verified to work, including after reboot.

Either solution would eliminate reliance on Docker's default forwarding behavior and allow the official Amnezia app to manage the VPN without requiring manual intervention.

Important Clarification: TUN Passthrough

This issue is not a request to eliminate /dev/net/tun passthrough.

The userspace amneziawg-go implementation requires access to TUN, and that requirement is expected.

In this Proxmox environment, TUN was explicitly passed through to the unprivileged LXC before the fresh installation.

The reported bug is specifically that IPv4 forwarding remains disabled inside the AmneziaWG Docker container despite successful VPN initialization and handshake.

Remaining Limitation

Although the workaround survives a normal LXC reboot, it has not yet been verified against an Amnezia app-managed update, reconfiguration, or Docker container recreation.

Because the Android app generates and manages /opt/amnezia/start.sh, future management operations could overwrite the modification.

For this reason, explicitly setting net.ipv4.ip_forward=1 during Docker container creation is preferable to relying on a manual modification of the generated startup script.

Expected Outcome

AmneziaWG 2 should initialize its Docker container with IPv4 forwarding enabled whenever the container is intended to route VPN client traffic, regardless of whether it is running inside a full VM or a compatible unprivileged LXC.

This would prevent installations from reporting success and establishing VPN handshakes while silently failing to route all client traffic.

<!-- gh-comment-id:6245931056 --> @samwathegreat commented on GitHub (Oct 18, 2026): ## Additional Findings — Root Cause, Verified Workaround, and Recommended Fix Further investigation identified why AmneziaWG 2 fails to route traffic when installed through the official Android app inside an unprivileged Proxmox LXC. ### Root Cause 1. The AmneziaWG 2 Dockerfile configures numerous networking parameters in `/etc/sysctl.conf`, but does not include `net.ipv4.ip_forward=1`. 2. The Dockerfile initially creates a placeholder `/opt/amnezia/start.sh`, which the official Android app subsequently replaces with a generated startup script. 3. The generated startup script successfully initializes the `awg0` interface and configures iptables FORWARD and MASQUERADE rules, but never enables IPv4 forwarding. 4. Docker creates the container with only the following explicit sysctl setting: `net.ipv4.conf.all.src_valid_mark=1` 5. IPv4 forwarding is enabled in the parent LXC (`net.ipv4.ip_forward=1`), but disabled inside the AmneziaWG Docker container (`net.ipv4.ip_forward=0`). 6. The problem was reproduced on two installations: - Existing unprivileged Proxmox LXC with Docker 29.8.0. - Completely fresh Debian 13 unprivileged Proxmox LXC, allowing Amnezia to install Docker 26.1.5 itself. A separate installation in a full Debian VM works without modification. ### Verified Workaround Adding the following line immediately after `#!/bin/bash` in `/opt/amnezia/start.sh` resolves the routing failure: ```bash sysctl -w net.ipv4.ip_forward=1 ``` This can be applied from the LXC using a single command: ```bash docker exec amnezia-awg2 sh -c 'grep -q "^sysctl -w net.ipv4.ip_forward=1$" /opt/amnezia/start.sh || sed -i "2i sysctl -w net.ipv4.ip_forward=1" /opt/amnezia/start.sh' ``` After enabling forwarding, both internet and LAN connectivity work immediately through the VPN. **Reboot test: PASSED.** The modified startup script survives a normal LXC reboot and automatically enables forwarding when the AmneziaWG container starts. No Docker image rebuild, Docker downgrade, or additional networking changes were required. ### Recommended Upstream Fix The preferred solution is to explicitly configure IPv4 forwarding when Amnezia creates the Docker container, alongside the existing `src_valid_mark` setting: ```yaml sysctls: net.ipv4.conf.all.src_valid_mark: "1" net.ipv4.ip_forward: "1" ``` Alternatively, the Amnezia app could include the following command in its generated startup script: ```bash sysctl -w net.ipv4.ip_forward=1 ``` The startup-script approach has been verified to work, including after reboot. Either solution would eliminate reliance on Docker's default forwarding behavior and allow the official Amnezia app to manage the VPN without requiring manual intervention. ### Important Clarification: TUN Passthrough This issue is **not** a request to eliminate `/dev/net/tun` passthrough. The userspace `amneziawg-go` implementation requires access to TUN, and that requirement is expected. In this Proxmox environment, TUN was explicitly passed through to the unprivileged LXC before the fresh installation. The reported bug is specifically that **IPv4 forwarding remains disabled inside the AmneziaWG Docker container despite successful VPN initialization and handshake**. ### Remaining Limitation Although the workaround survives a normal LXC reboot, it has **not yet been verified against an Amnezia app-managed update, reconfiguration, or Docker container recreation**. Because the Android app generates and manages `/opt/amnezia/start.sh`, future management operations could overwrite the modification. For this reason, explicitly setting `net.ipv4.ip_forward=1` during Docker container creation is preferable to relying on a manual modification of the generated startup script. ### Expected Outcome AmneziaWG 2 should initialize its Docker container with IPv4 forwarding enabled whenever the container is intended to route VPN client traffic, regardless of whether it is running inside a full VM or a compatible unprivileged LXC. This would prevent installations from reporting success and establishing VPN handshakes while silently failing to route all client traffic.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#3164
No description provided.