There's been ongoing discussion on the answer posted by John. But I didn't find those answers/discussions working towards a plausible resolution. May be I missed something? But surely I read tons of articles/posts by now.
So here's my answer which should resolve the issue of the main question relating to assigning IP address while using Host Only Network Adapter.
Context
When I spin-up a virtual machine with a Host Only Network Adapter by default, the VM doesn't get an IP on an interface called enp0s8
. This interface is valid for Debian 10. But, I am able to see an IP is assigned to enp0s3
interface.
Yes, all the preceding comments are correct mentioning IP does not get assigned! However, the idea of assigning a VM to a Host Only Adapter is to be able to communicate to this new VM from host machine. And since, there's no IP assigned to this VM, host machine simply will not be able to connect to it.
Resolution
For Debian/Ubuntu OS, you need to edit this file /etc/network/interface
.
Then update the file with below contents. Note, there are 4 spaces for address
and netmask
directives.
auto enp0s8 allow-hotplug enp0s8
iface enp0s8 inet static
address 192.168.56.11
netmask 255.255.255.0
Please note, I set up static
instead of dhcp
. This we should be able to assign a static IP to a particular VM. Now, perform restart on the VM.
Test
Do a ping test from host machine with VM static IP: 192.168.56.11
. You should be able to ping success result. As such, you should be able to connect to this VM using SSH login as well i.e., ssh [email protected]
. Use the username and password of your VM OS.
Hope this helps someone!