Linux: bridge containers can't reach Tailscale/VPN networks (NAT only on default-route NIC, bridges in no firewalld zone)

Abierto
#261 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
linux, rust

Línea de trabajo

Start with crates/kiri-init/src/linux/netlink.rs and crates/kiri-init/src/linux/net.rs, which the issue identifies for NAT installation and uplink selection. Trace bridge creation and teardown to find where firewalld zone membership can be managed. Reproduce the reported container-to-tailnet failure and verify that bridge containers can reach routed networks while internet access still works.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Kiri version and system

Kiri Lite 0.2.1 (.rpm), Fedora 44, kernel 7.2, x86-64. firewalld running (default zone FedoraWorkstation), Tailscale up. Two default routes: wired (metric 100) and wifi (metric 600).

What you did

From a container on the default bridge, connected to a host on the tailnet:

docker run --rm alpine nc -zw3 100.x.y.z 9010
What happened

nc fails with "no route to host". Internet from the same container works (wget http://1.1.1.1). --network host reaches the tailnet. Rootless Docker on the same host reached the tailnet from bridge containers.

I found two gaps; both must be fixed for it to work.

1. NAT only on the default-route NIC.

  • crates/kiri-init/src/linux/netlink.rs install_nat_from: the IPv4 rule is oif <uplink> masquerade (here oif "enp6s0" masquerade).
  • crates/kiri-init/src/linux/net.rs host_uplink: the uplink is the first default route in /proc/net/route, read once at engine start.
  • Traffic out of any other interface keeps its 172.x source: tailscale0 (routes in table 52), WireGuard/VPN interfaces, the wifi NIC after the wired link drops.

2. Kiri bridges are in no firewalld zone.

  • firewalld's filter_FORWARD_POLICIES ends in reject with icmpx admin-prohibited. The zone with forward: yes only accepts oifname of its own interfaces (enp6s0, wlp5s0). kiri0 and tailscale0 have no zone, so forwarded packets to tailscale0 are rejected, and the container sees EHOSTUNREACH.
  • Internet works only because enp6s0 is a zone interface.
  • Docker handles this by adding its bridges to firewalld's docker zone (target ACCEPT) with the docker-forwarding policy.

Tested on the host (runtime only, reverted after):

Change Container to tailnet Container to internet
none fail ok
firewall-cmd --zone=docker --add-interface=kiri0 fail ok
that + nft add rule ip kiri postrouting ip saddr 172.16.0.0/12 oifname != "kiri*" masquerade ok ok
What you expected instead

Bridge containers reach every network the host can route to, as with Docker. Suggested fix:

  • Masquerade by source, as Docker does (-s <subnet> ! -o <bridge> -j MASQUERADE) and as Kiri's IPv6 rule already does: ip saddr <subnet> oifname != "kiri*" masquerade per network. This also removes the need to re-read the default route when it changes.
  • When firewalld runs (org.fedoraproject.FirewallD1 on D-Bus), add each kiri* bridge to a zone with target ACCEPT (Kiri's own zone, or the docker zone as Docker does), and remove it when the bridge goes away.
Anything else

Related: #247 (no forward/NAT rules with FORWARD policy DROP under ufw), #44 (same NAT gap on WSL2).

Workaround: network_mode: host for containers that need the tailnet or a VPN.

Lenguaje dominante
Rust
Estrellas
7.5k
Forks
329
Merge medio
7 h 48 min
PR fusionados (30 d)
105

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de libracoder/kiri

Todos los issues de libracoder/kiri

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.