[systemd-devel] systemd-nspawn network-interface

poma pomidorabelisima at gmail.com
Tue Apr 18 16:24:34 UTC 2017


On 17.04.2017 11:59, Lennart Poettering wrote:
> On Thu, 13.04.17 16:08, poma (pomidorabelisima at gmail.com) wrote:
> 
>> Hello
>>
>> Regaining of the network-interface, as is stated in the manual, ain't happening;
>> man 1 systemd-nspawn
>> ...
>> OPTIONS
>> ...
>> --network-interface=
>>   Assign the specified network interface to the container.
>>   This will remove the specified interface from the calling namespace and
>>   place it in the container.
>>   When the container terminates,
>>   it is moved back to the host namespace. [...]
>>
>> Given what's actually going on, should be stated;
>> --network-interface=
>>   Assign the specified network interface to the container.
>>   This will remove the specified interface from the calling namespace and
>>   place it in the container.
>>   When the container terminates,
>>   considering that the specified interface is not moved back to the host namespace,
>>   specific kernel module need to be reloaded to move it back to the host namespace. [...]
> 
> Upgrade your kernel! This all works correctly on current kernels:
> network interfaces will now safely migrate back to the parent
> namespace when a network namespace dies.
> 
> We usually don't document bugs in other software in systemd, but
> instead ask people to run current systemd only in conjunction with
> somewhat current kernels.
> 
> Lennart
> 

There you go!

# hostnamectl | grep -v 'host\|ID'
         Icon name: computer-desktop
           Chassis: desktop
  Operating System: Fedora 26 (Twenty Six)
       CPE OS Name: cpe:/o:fedoraproject:fedora:26
            Kernel: Linux 4.11.0-0.rc7.git0.1.fc26.x86_64
      Architecture: x86-64

# machinectl 
No machines.

# nmcli device | grep enp3s0
enp3s0      ethernet  unmanaged     --         

# networkctl | grep enp3s0
WARNING: systemd-networkd is not running, output will be incomplete.

  9 enp3s0           ether              n/a         unmanaged 

# systemd-nspawn --version
systemd 233
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN default-hierarchy=hybrid

# systemd-nspawn --boot --machine fedora25 --image fedora25.raw --network-interface=enp3s0
Spawning container fedora25 on /[...]/fedora25.raw.
Press ^] three times within 1s to kill container.
systemd 231 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.

Welcome to Fedora 25 (Twenty Five)!

Set hostname to coconut.
[...]
Fedora 25 (Twenty Five)
Kernel 4.11.0-0.rc7.git0.1.fc26.x86_64 on an x86_64 (console)

coconut login: root
Password: 
Last login: [...] on console

# hostnamectl | grep -v 'host\|ID'
         Icon name: computer-container
           Chassis: container
    Virtualization: systemd-nspawn
  Operating System: Fedora 25 (Twenty Five)
       CPE OS Name: cpe:/o:fedoraproject:fedora:25
            Kernel: Linux 4.11.0-0.rc7.git0.1.fc26.x86_64
      Architecture: x86-64

# nmcli device | grep enp3s0
Error: NetworkManager is not running.

# networkctl | grep enp3s0
  9 enp3s0           ether              routable    configured

# poweroff 
[...]
Powering off.
Container fedora25 has been shut down.

# nmcli device | grep enp3s0

# networkctl | grep enp3s0
WARNING: systemd-networkd is not running, output will be incomplete.

# systemd-nspawn --boot --machine fedora25 --image fedora25.raw --network-interface=enp3s0
Spawning container fedora25 on /run/media/test/cb2b679b-fac2-4e92-86d2-665bbe29f2c4/nspawn/fedora25.raw.
Press ^] three times within 1s to kill container.
Failed to resolve interface enp3s0: No such device
[...]


Feel free to ask, I can do more tests.



More information about the systemd-devel mailing list