Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a number of virtual machines on a Ubuntu 12.04 host. For various reasons all these VMs need fixed IP addresses. The laptop in question is used for demonstrations -- and this is where the problems arise...

Depending on the circumstances I will either use WiFi or a mobile tether to get an internet connection, which in both cases leads to the laptop being assigned an address via DHCP. Frequently this dynamic address is on a different subnet to the one used by the fixed ones (192.168.0/20). This makes the static addresses unreachable from the host OS.

After some thought, it seems the most elegant solution is to create a separate LAN on the host (for the subnet used by the VMs) and then bridge it to whatever subnet is assigned to the host.

Bear in mind the VM's only need to communicate with each other and the host. They do not need access beyond that.


  • is this the best approach?
  • if, it is how could I go about implementing it?

Many thanks.

share|improve this question

If you're using VMware all you need to do is assign these virtual machines to a virtual LAN that has not connection with VMware itself nor the host machine. This is called "LAN segments" and it's easy to find under the Network Interface settings of each machine.

All you have to do is create a new LAN segment for the first machine, then add the other ones to the same network:

enter image description here

This is similar to the host-only network but with the difference that machines can't contact the hosts nor other external networks (Internet) so it's like having a LAN with those machines only. Since there's not a DHCP server in this network, you'll have to add the IP's manually in each system.

If you want them to communicate with the host, you need the host-only setting. In this case, the host will have the lower IP, since it will act as a gateway (but without forwarding packets to other networks).

share|improve this answer
This looks very promising! Thanks darent – user258959 Mar 16 '14 at 22:03
I've been using this myself for months in my sysadmin course. Never had a problem (only when I tried bridge mode, sometimes DHCP from a real network fails to assign an IP to the virtual machines). Hope it helps – darent Mar 16 '14 at 22:11

Any type 2 hypervisor will be already having virtual networks of multiple types (bridged, host only, internal network).

Bridged: VM will be attached to your physical NIC as your host do, and will acquire IP from DHCP -if enabled.

Host only: VM can only communicate with HOST and not beyond that (Option should have been enabled when you were installing VMWare Workstation) more details Here

-NAT : VMs will be natted to your host IP and will communicate beyond host through its IP.

share|improve this answer
Thanks Ahmadgeo, this is very useful. – user258959 Mar 16 '14 at 22:05

When you install the metapackage apt-get install ubuntu-virt, you'll have a NATed bridge called virbr0 right on your Desktop, which all your KVM Virtual Machines will be attached to, so, I think that this will be enough for you...

You'll probably need the virt-manager too.

share|improve this answer
I'm using Vmware Workstation. Does your reply remain valid? Tks. – user258959 Mar 16 '14 at 21:41
I've never used VMWare Workstation before, so, honestly, I don't know but, it probably have a similar setup. – ThiagoCMC Mar 16 '14 at 21:47
Thanks, Thiago. I think what I'm looking for is something that will create a "virtual" LAN at the OS level, not at the VM level. Then again, I'm very much out of my comfort zone here. – user258959 Mar 16 '14 at 21:52
Okay, no problem... But, just for the record, "ubuntu-virt" metapackage deploys the "virtual LAN" right on O.S., not at the "VM level". ;-) – ThiagoCMC Mar 16 '14 at 22:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.