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:
- The VMs need to be able to access the Internet via whatever connection the laptop has.
- 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).
- 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:
- NAT – appears as eth0 – provides Internet access whether I’m using wired or wireless
- 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.
Filed under: howto, technology | 2 Comments
Tags: bridged, eth0, eth1, host only, howto, internal, Linux, NAT, network, networking, Putty, SSH, Ubuntu, VirtualBox, virtualisation, virtualization
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.