Looking at the documentation for
systemd-nspawn, it must have been intended to have a very user-friendly way to launch containers in a different network namespace. You use the
-n option, and simply enable
systemd-networkd.service on both ends. The container gets its own IP address in one of the "private" ranges. (DNS might require some additional step).
The result is I get an IP address in the range
169.254.*.*. The default route points at the
host0 interface without going through any gateway/router. Attempts to reach internet servers e.g.
18.104.22.168 fail with "No route to host". (No point working out DNS if this doesn't work).
If I run
tcpdump -i ve-fedora-25 on the host, I can see the DHCP requests, but they are not responded to. systemd-networkd is definitely running on the host. The host-side logs show "Gained carrier" on
ve-fedora-25, and networkctl shows this as "routable" & "configured" all in green.
My system is Fedora 25. I want an OS container I can connect to using TCP/IP, and at the same time be able to connect out to the world (e.g. to run the
dnf package manager). Just as
libvirt VMs work so easily out-of-the-box. What has gone wrong?