NIC reattach on sunstone breaks /etc/network/interfaces

Hi there!

I’m running Ubuntu 14.04 from the marketplace and I have the network fully setup with one physical connection on the host called br0. On vm creation the network is fully functional and a quick ifconfig on the vm returns both lo and eth0. I can ping both the vm and ping out from it. However if I detach the NIC from the vm and then simply attach it again and reboot the vm, the vm’s eth0 iface is gone and won’t start [see attachment]. Turns out it’s because the vm’s /etc/network/interfaces file not only has the old ip specified in eth0 [which differs from the new one in the vm’s network panel in sunstone], but is also broken as the word eth0 doesn’t show up in the iface definition lines [see attachment]. Manually fixing the file works but only until vm reboot. I’ve tried all combinations of nic detach/reattach, vm reboot, and host reboot, with no success. This happens on new vms as well. I have an ubuntu 14.04 host and I’m on one 4.14.2.

Thanks in advance for your help!

Can you send us this information?

  • output of ip a in that VM
  • file. It should be in /var/lib/one/<vmid>/
  • output of onevm show -x <vmid>


Thanks so much for your reply.

Absolutely: here is an ip a on a vm immediately after reboot so before manual correction of /etc/network/interfaces:

And here it is after:

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:c0:a8:01:6f brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::c0ff:fea8:16f/64 scope link 
       valid_lft forever preferred_lft forever```

Here is `` [brakets around pound sign added by me for correct formatting] :
```root@ubns01:~# cat /var/lib/one/vms/32/ 
[#] Context variables generated by OpenNebula

And here is `onevm show -x 32` immediately after vm reboot [so no manual correction of interfaces file] :

Thanks again for your help!


The problem is that OpenNebula does not regenerate the context script.

To find the correct interface we try to find one with the same mac address. In this case there is no interface with that specific mac address a malformed interface configuration is added. I’ve opened a ticket for the context packages to skip these cases:

While OpenNebula does not regenerate the context information I don’t recommend you to detach interfaces defined on VM instantiation.

Ok I see thank you very much for opening an issue!

I’ll try to avoid that but as for now we have three production vms that we had to migrate from to Is there any way I can manually fix this for these vms?

Thanks again!

I think the best way to fix this is disabling contextualization in that machine and manually configuring interfaces. You can do this deleting the link SXXvmcontext from /etc/rc2.d or /etc/rc3.d, depending on your distribution.

Hi! I’m very sorry I didn’t reply back at that time. I deleted both files and it works now: the vm keeps the network config across reboots without it being overwritten by the context.

I saw by chance that coincidentally you just added this issue’s solution to the v5.0.0 milestones.

Thank you very much again for your help!