SOLVED Ubuntu VM boots with no DHCP lease

bar17

Dabbler
Joined
Oct 24, 2019
Messages
33
Hello,

I just created a Ubuntu 18.04 LTS virtual machine using the VNC web interface. I had oppenssh-server installed on initial installation. I am using a virtIO disk and virtIO networking.

If I turn the machine on I cannot immediately SSH into my account. Instead, I have to start the web interface, login, and then ask for an IP address.

I initially realized the problem by typing ifconfig and only seeing a loopback device. Then running sudo dhclient again followed by ifconfig demonstrated both the loopback device and a internal IP. My router then shows a new MAC and IP at this time as well and I am able to SSH in. Rebooting the virtual machine causes the IP address to be lost again.

I have never had this problem with a Ubuntu Virtual machine in the past running virtualbox. However, that is on a Window Desktop and my goal is to run multiple headless servers using FreeNAS.

Any help would be greatly appreciated.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Review your virtual machine VNC device settings. If "Delay VM Boot until VNC Connects" is selected, deselect this setting and save.
 

bar17

Dabbler
Joined
Oct 24, 2019
Messages
33
Review your virtual machine VNC device settings. If "Delay VM Boot until VNC Connects" is selected, deselect this setting and save.

I have already tried this and it is currently deselected.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Not come across this behaviour myself as I tend assign a static IP to my virtual machines rather than rely on DHCP. Have you checked over your Ubuntu VM's netplan config is using the correct interface, etc?
 
Last edited:

bar17

Dabbler
Joined
Oct 24, 2019
Messages
33
Not come across this behaviour myself as I tend assign a static IP to my virtual machines rather than rely on DHCP. Have you checked over your Ubuntu VM's netplan config is using the correct interface, etc?

The VM is definitely using the correct interface, I only have it plugged into one networking interface and I used the same one as the system.

I have recreated the entire virtual machine from scratch using VirtIO disk and the Intel 82545 NIC. Same problem. I can reliably access the machine via VNC but if I issue the sudo shutdown -r now or sudo shutdown -P now command on restart I cannot SSH into the machine. I must VNC via web interface. Then login, then run sudo dhclient. Then, it gets assigned an IP address on the virtual machine and I can SSH into it.

I am using DHCP at the moment, but my lease has not expired, this is over the span of a few minutes. It is for all wants and purposes static. I can see the MAC address assigned to the IP in my router networking window.

I would like to be able to disable VNC permanently and know that on reboot I can SSH into the machine.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Just to clarify, I meant the interface name within the vm's netplan config file, which should match the interface name as listed by ip a in your Ubuntu vm.
 

bar17

Dabbler
Joined
Oct 24, 2019
Messages
33
I didn't quite know what you meant when you made this reply/comment.

Just to clarify, I meant the interface name within the vm's netplan config file, which should match the interface name as listed by IP a in your Ubuntu vm.

But then I found a very helpful post by someone named "KrisBee" from 2017! ;)

My /etc/netplan/01-netcfg.yaml file:
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s5: dhcp4: yes

I edited to enp0s4 and ran netplan apply and it worked! Networking is up on reboot. The reason it changed I believe is because I had removed the CD-ROM device, as you alluded to in your above post.

I guess I wouldn't call this a bug... but it certainly is non desirable behavior. Should I post this somewhere more formally?

Thank you very much for being persistent with your reply's @KrisBee
 
Last edited:

bar17

Dabbler
Joined
Oct 24, 2019
Messages
33
Interestingly, deleting the VNC device, after all of this does not yet again change the 'netplan' interface relative to the interface listed by 'ip a'. So I have now deleted that and only have a Disk and NIC as devices.

Additionally, I changed the NIC adapter type from the Intel back to VirtIO and there are no problems.
 
Last edited:

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288

cruz4221

Cadet
Joined
Aug 6, 2021
Messages
4
I'm having this issue in every new virtual machine created. Ubuntu 18.04 LTS TrueNAS 12
 
Top