Amelie
Amelie

Reputation: 583

Assign IP address to a virtual machine using virtualbox

How can I connect two VMs within a network? I chose the option internal network for both of them, but no IP address was assigned to each VM.

This is what I obtained when doing the command ifconfig:

ifconfig result

NB: I am using virtualbox as hypervisor and 2 VMs (UBUNTU OS)

Upvotes: 1

Views: 12710

Answers (2)

Tomader
Tomader

Reputation: 1

I'm not sure if this is what you're asking for, but I recently established a connection between two VM(both are Ubuntu), for chatting! I made both have their network settings attached to "bridged adapter", so their IPs were shown with "ifconfig". After that I used "netcat" tool for the connection.

Upvotes: 0

jming
jming

Reputation: 110

I prefer using the "NAT Network" type when connecting two guests to one another, since it essentially combines the features of the NAT and Internal Network options. If that sounds like what you want, these steps should get you there, otherwise you can skip them.


  1. Open VirtualBox, go to Preferences (Windows it's under File, Mac under the application name), and go to the Network tab.
  2. You should already be on the NAT Network tab. Click the button with the + to create the network. If you want to rename it, hit the screwdriver icon.
  3. Press OK, then go to the settings for each of your guest OSes and make the following change: Under Network, change an adapter's network type to "NAT Network" and make sure it selected the network you just created. If the box already has a NAT-type adapter, change that one to NAT Network - you don't need both and it will only serve to confuse your guest OS if they're both there.
  4. All done! Boot up the OSes and they should be automatically assigned IPs on the same network by VirtualBox's DHCP server.

If you want to stick with the internal network option, I believe you can simply set the IP manually from your guest OS - in Ubuntu go to System Settings→Network, select your adapter (most likely called "Wired"), then hit Options, and enter your desired IP configuration under "IPv4 Settings." After that point the guest machines should be able to find each other at their self-defined IP addresses. (I seem to remember that working for me before, but it's been a while since I've tried it, so let me know if that doesn't work.)

You can read more here and here.

Upvotes: 0

Related Questions