# Netcup /64 IPv6, Docker Dual-Stack & Firewall Hardening Guide (incl. IPv6-Only NAT64)

> Configure Netcup routed /64 IPv6 on Debian 12, enable Docker dual-stack, prevent bypassed host firewall ports via SCP + 127.0.0.1, and run IPv6-only NAT64.

- Canonical URL: https://euserverlab.com/guides/docker-ipv6-ufw-firewall-netcup-setup-guide/
- Language: en
- Published: 2026-11-13 | Updated: 2026-11-22
- Publisher: EUServerLab (https://euserverlab.com/methodology/)

## Key Findings (TL;DR)
- Every Netcup Root-Server and VPS routes a dedicated /64 IPv6 subnet via link-local gateway fe80::1 — assign ::1/64 statically so host and container addresses remain predictable.
- Publishing container ports as -p 5432:5432 inserts DNAT rules ahead of UFW/INPUT chains, exposing databases publicly! Bind internal services to 127.0.0.1:5432:5432 and enforce perimeter drops in Netcup's outer SCP Firewall.
- Docker Engine 27+ supports native IPv6 + ip6tables on bridge networks out of the box when ipv6, ip6tables, and a private ULA fixed-cidr-v6 (/80) are enabled in /etc/docker/daemon.json.
- Ordering a server with Netcup's IPv6-Only Geek Saver (-€0.50/mo net / -€0.60/mo gross) works cleanly with GitHub, npm, and Docker Hub once you configure public DNS64/NAT64 resolvers.

## Execution Checklist
1. **Verify Static /64 IPv6 & fe80::1 Gateway on Primary Interface**: Confirm your SCP-assigned /64 prefix::1 is bound on ens3 with fe80::1 as default IPv6 gateway and test ping6 -c 3 2606:4700:4700::1111.
2. **Enable ip6tables & Private ULA /80 in /etc/docker/daemon.json**: Turn on ipv6, ip6tables, and fixed-cidr-v6 with a private ULA /80 subnet (fd00:dead:beef:1::/80) for stateful IPv6 NAT, then restart docker.
3. **Bind Internal Ports to 127.0.0.1 & Lock Down Outer SCP Firewall**: Publish databases on 127.0.0.1 only and restrict inbound public traffic at the hypervisor layer in Netcup SCP -> Firewall to TCP 22/80/443 and UDP 443.

---

Two networking mistakes cause more headaches on European Linux servers than any hardware bottleneck: **Docker containers silently bypassing host `ufw` rules**, and **broken `/64` IPv6 routing** (especially when toggling Netcup's **IPv6-Only Geek Saver** in our [Real TCO Calculator](/tools/calculator/) to save `€0.50/mo` net / `€0.60/mo` gross). Here is our verified production setup from Nuremberg (`AS197540`).

## 1. Clean `/64` IPv6 Host Addressing (`fe80::1` Link-Local Gateway)

Netcup assigns every server a static `/64` IPv6 prefix (visible under **SCP → Network**) routed via the hypervisor's link-local gateway `fe80::1`. On Debian 12 (`ens3`), bind `::1/64` statically on the host so outbound IPv6 traffic and Docker's `ip6tables` NAT egress share a deterministic primary address:

```ini
# /etc/network/interfaces (replace 2a03:4000:60:abcd::/64 with your SCP /64 prefix)
iface ens3 inet6 static
    address 2a03:4000:60:abcd::1/64
    gateway fe80::1
    dns-nameservers 2606:4700:4700::1111 2620:fe::fe
```

Verify dual-stack reachability immediately with `ip -6 route show default` and `curl -6 -I https://cloudflare.com`.

## 2. Enabling Native IPv6 + `ip6tables` Isolation in Docker Engine

Without `ip6tables: true`, enabling IPv6 in Docker can leave container IPv6 ports unfiltered. Configure `/etc/docker/daemon.json` on Docker Engine 26/27+ so bridge networks receive Dual-Stack + stateful `ip6tables` NAT/filter protection:

```json
{
  "ipv6": true,
  "ip6tables": true,
  "experimental": false,
  "fixed-cidr-v6": "fd00:dead:beef:1::/80",
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "20m",
    "max-file": "3"
  }
}
```

Using a Unique Local Address (`fd00:...::/80`) with Docker's built-in IPv6 NAT (`ip6tables: true`) gives every container outbound IPv6 connectivity (via the host's `2a03:4000:...::1` address) **without** assigning publicly routable IPs directly to internal Redis or PostgreSQL containers!

## 3. Stopping the Docker `UFW` Bypass (Defense-in-Depth)

Whenever a `docker-compose.yml` file declares `ports: ["5432:5432"]`, Docker rewrites kernel `PREROUTING` / `FORWARD` chains **before** `ufw`'s `INPUT` rules evaluate—exposing your database to the entire internet even when `ufw status` says `5432 DENY`. Apply all three layers below so a misconfigured Compose stack can never leak:

| Defense Layer | Exact Configuration | What It Prevents |
| :--- | :--- | :--- |
| **1. Compose Loopback Bind** | Write `127.0.0.1:5432:5432` (or omit `ports:` and join an internal Docker bridge) | Keeps internal ports off `0.0.0.0` and `[::]` completely |
| **2. Kernel `DOCKER-USER` Chain** | Drop unsolicited external `FORWARD` packets on `ens3` except `80/443` | Blocks accidental `-p 8080:8080` mistakes inside Linux |
| **3. Outer Netcup SCP Firewall** | **SCP → Network → Firewall**: Allow `TCP 22, 80, 443` & `UDP 443`, default **`DROP`** | **Hypervisor-enforced**: blocks scans outside the VM before Docker sees a single packet! |

To verify what is genuinely reachable from outside your VM, run `ss -tulnp` on the host and scan your public IPv4/IPv6 from a separate machine.

## 4. Running Pure IPv6-Only (`-€0.50/mo` Net) with DNS64/NAT64

Deselecting public IPv4 during Netcup checkout drops a [VPS pico G11.5s](/models/vps-pico-g11-5s/) to **`€1.35/mo` net (`€1.61/mo` gross; vouchers are not combinable on VPS Lite)** and saves **`€6.00/yr` net (`€7.20/yr` gross)** on any [G12.5 Root-Server](/root-server/) or [VPS](/vps/). Because legacy endpoints like `github.com` still rely on IPv4 `A` records, add European public **DNS64/NAT64** resolvers (`nat64.net` operated in Europe) so `git clone`, `curl`, and `apt` transparently reach IPv4-only hosts over IPv6:

```bash
# Configure European DNS64/NAT64 resolvers on an IPv6-only Netcup VM
sudo mkdir -p /etc/systemd/resolved.conf.d
cat <<'EOF' | sudo tee /etc/systemd/resolved.conf.d/nat64.conf
[Resolve]
DNS=2a00:1098:2b::1 2a00:1098:2c::1 2a01:4f8:c2c:123f::1
FallbackDNS=2606:4700:4700::64 2606:4700:4700::6400
EOF
sudo systemctl restart systemd-resolved

# Test pulling from IPv4-only GitHub over synthesized NAT64!
curl -I https://github.com
```

For inbound visitors on IPv4-only mobile/home ISPs, point an `AAAA` record on **Cloudflare DNS (Orange Cloud Proxied)** to your server's `2a03:4000:...::1` address—Cloudflare terminates both IPv4 and IPv6 at the edge for `€0` and proxies upstream to your Netcup origin over pure IPv6!

## Frequently Asked Questions

### Why can scanners still reach my PostgreSQL or Redis container after I enabled UFW?

When you publish a Docker port on 0.0.0.0 (for example -p 5432:5432), Docker programs DNAT rules in the kernel PREROUTING/FORWARD path that bypass standard UFW INPUT rules. Always bind internal containers to loopback (-p 127.0.0.1:5432:5432) AND add an explicit hypervisor-level allowlist in Netcup SCP -> Firewall, which filters packets outside your VM before Docker ever sees them.

### What IPv6 gateway does Netcup use across Nuremberg, Vienna, Amsterdam, and Manassas?

Across all G12.5 and G11.5s KVM hosts, Netcup routes your assigned /64 IPv6 prefix over the link-local gateway fe80::1 on your primary VirtIO interface (ens3 / eth0).

### Can an IPv6-only Netcup server (-€0.50/mo net saver) pull from GitHub or IPv4-only APIs?

Yes! Set DNS64 resolvers (such as nat64.net 2a00:1098:2c::1 and 2a00:1098:2b::1) in /etc/systemd/resolved.conf or /etc/resolv.conf for outbound IPv4 synthesis, and place Cloudflare CDN (free dual-stack proxy) in front of your AAAA record so IPv4 visitors can reach your web apps.

---
Source: EUServerLab (https://euserverlab.com/guides/docker-ipv6-ufw-firewall-netcup-setup-guide/) | Open Telemetry Dataset: https://euserverlab.com/benchmarks/vps-500-g12-5.json
