Network config for Linux VMs on a laptop

08Oct11

I run a bunch of Linux (mostly Ubuntu) VMs on my main machine at home, which happens to be a laptop. I use VirtualBox, but what I have to say here is probably applicable to most host based virtualisation environments.

My requirements are pretty simple:

  1. The VMs need to be able to access the Internet via whatever connection the laptop has.
  2. Internet access should continue to work if I switch between wired and wireless connections (e.g. if I undock the laptop and take it into the lounge).
  3. I need to be able to access the VMs over SSH using PuTTY.
Sadly none of the networking modes supports these:
  • Not attached – obviously
  • NAT – provides Internet access, but doesn’t give an IP that I can SSH to
  • Bridged – makes me choose between wired or wireless
  • Internal network – doesn’t do any of the things I want (at least not without much extra work/plumbing)
  • Host only – doesn’t give me Internet access
  • Generic driver – don’t even go there
I got to thinking that somebody should do a lightweight VM that would act as a router etc. between the internal network and the host, but that’s not the answer either.
The correct approach was obvious once I thought about it – use two network adaptors:
  1. NAT – appears as eth0 – provides Internet access whether I’m using wired or wireless
  2. Host only – appears as eth1 – provides an IP that I can connect to using PuTTY
After adding the second adapter I had to add a few lines to /etc/network/interfaces thus:
# Host only interface
auto eth1
iface eth1 inet dhcp
Once that was done I needed to ‘ifup eth1’ to get things going. Then ifconfig revealed a 192.168.56.x IP that I could use for the Putty connection.


2 Responses to “Network config for Linux VMs on a laptop”

  1. 1 Scooter

    Is this how you run your bittorrent tracker? Like to know what software you use for this and how you configure it, perhaps that would make a good follow up post?

    • I don’t run a bit torrent tracker – just a client. The client runs on Windows (I haven’t found one I get on with on Linux) on my always on Microserver rather than my laptop.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: