I was at a monthly InfoSec meetup last week ready to start a CTF. I’d set up my Kali VM day before (inspiring me to write this amazing guide). I knew how to connect to two networks beforehand, but it just wasn’t working for me that night.

So, I’ve finally got it up and running. Let’s do it together!

First thing’s first. Let’s set up the network adapters. Open up VirtualBox, click the Kali VM, then click Settings.

My first adapter is my Host-only Adapter. This allows all the VMs to communicate on a separate network internally on my host machine.

Host-only Adapter

Now, I want my Kali VM to be able to access the Internet as well. Rather than constantly switching between my host and VM to Google stuff, I’d rather just do it all in the one machine (which also simplifies copy and pasting). So, let’s set up an adapter with NAT. This essentially sets up the VM as a separate machine and gets its own IP on the network.

NAT adapter

Simple, right? That’s what I thought last week. Then I booted into Kali and found I only had access to one network, and could only switch between them.

So I spent ages trying to mess around with VirtualBox settings. Got nowhere.

Alas, StackOverflow comes my rescue yet again. I just need to edit the  /etc/network/interfaces file to set both adapters up on boot.

Let’s open it up.

Here’s what mine looked like before I tinkered with it.

I want both eth0  and eth1  (the two adapters we set up) to be activated on boot. auto  does that. Now I want to configure both to get an IP address. That’s what iface inet dhcp  does. The host machine acts as a DHCP server for the vboxnet0  network on the Host-only adapter, whereas your router will act as the DHCP server for the NAT adapter, just like normal.

So here’s what it looks like after.

Now let’s boot up and see if it worked:

NAT working on left, Host-only working on right


Note: For anyone who’s struggling with DNS issues, you’ll need to set your NAT adapter to be the last interface in /etc/network/interfaces.