DEV Community

Cover image for The Most Confusing Thing in VirtualBox: Networking Explained
Arashad Dodhiya
Arashad Dodhiya

Posted on

The Most Confusing Thing in VirtualBox: Networking Explained

If you've ever run this command in Kali Linux:

ip a
Enter fullscreen mode Exit fullscreen mode

you've probably seen something like this:

lo      127.0.0.1
eth0    10.0.2.15
eth1    192.168.56.10
docker0 172.17.0.1
Enter fullscreen mode Exit fullscreen mode

And then immediately asked:

Why does my machine have multiple IP addresses?

What are eth0 and eth1?

Which IP should I use?

Why can Windows access one IP but not the other?

You're not alone.

This is probably one of the most confusing topics for beginners learning VirtualBox, Kali Linux, and networking.

Let's fix that.


First: What Is an IP Address?

Think of an IP address as a house address.

If someone wants to send you a letter, they need your address.

The internet works the same way.

Every device needs an address so other devices know where to send data.

Example:

Your Phone
192.168.1.10

Your Laptop
192.168.1.20

Your Router
192.168.1.1
Enter fullscreen mode Exit fullscreen mode

Without addresses, communication wouldn't be possible.


Then Why Does Kali Have Multiple IP Addresses?

Because Kali has multiple network interfaces.

Think of a computer as a building.

A building can have:

  • Front Door
  • Back Door
  • Garage Door

Each door connects to a different area.

Computers work similarly.

Each network interface is a separate network door.


Understanding Network Interfaces

When you run:

ip a
Enter fullscreen mode Exit fullscreen mode

Linux shows every network interface available on the system.

Example:

lo
eth0
eth1
docker0
Enter fullscreen mode Exit fullscreen mode

Each one serves a different purpose.


Interface 1: lo (Loopback)

lo
127.0.0.1
Enter fullscreen mode Exit fullscreen mode

This is called the loopback interface.

Think of it as talking to yourself.

Visual:

Kali
 │
 └── talks to Kali
Enter fullscreen mode Exit fullscreen mode

When you visit:

http://127.0.0.1
Enter fullscreen mode Exit fullscreen mode

the traffic never leaves your machine.

It doesn't reach:

  • Windows
  • Your Router
  • The Internet

Everything happens internally.

This is commonly used by:

  • Web servers
  • Databases
  • Local applications

Interface 2: eth0

In my lab:

eth0
10.0.2.15
Enter fullscreen mode Exit fullscreen mode

This interface was created by VirtualBox using NAT mode.

Visual:

Kali
  │
  ▼
VirtualBox NAT
  │
  ▼
Windows
  │
  ▼
Internet
Enter fullscreen mode Exit fullscreen mode

This interface allows Kali to:

  • Browse websites
  • Download tools
  • Run apt update
  • Access the internet

Example:

ping google.com
Enter fullscreen mode Exit fullscreen mode

Most likely uses eth0.


Interface 3: eth1

In my lab:

eth1
192.168.56.10
Enter fullscreen mode Exit fullscreen mode

This interface belongs to a Host-Only network.

My Windows machine has:

192.168.56.1
Enter fullscreen mode Exit fullscreen mode

Visual:

Windows
192.168.56.1
       │
       │
       │
Kali
192.168.56.10
Enter fullscreen mode Exit fullscreen mode

This network exists entirely inside my laptop.

No internet.

No router.

No external devices.

Just Windows and the virtual machines.


Why Cybersecurity Labs Use Host-Only Networks

Imagine you are learning:

  • Nmap
  • Metasploit
  • Burp Suite
  • Web Security Testing

You need targets.

Instead of attacking real systems, you create a private lab.

Example:

Windows
192.168.56.1

Kali
192.168.56.10

Metasploitable
192.168.56.20
Enter fullscreen mode Exit fullscreen mode

Now Kali can safely scan and test Metasploitable.

Everything stays inside your laptop.


What Is a Virtual NIC?

NIC stands for:

Network Interface Card
Enter fullscreen mode Exit fullscreen mode

A real computer has a physical network card.

A virtual machine doesn't.

So VirtualBox creates a virtual network card.

Visual:

Physical Laptop
│
├── Real Network Card
│
└── VirtualBox
      │
      ├── Virtual NIC (eth0)
      │
      └── Virtual NIC (eth1)
Enter fullscreen mode Exit fullscreen mode

To Kali, these look like real network adapters.

Even though they are completely virtual.


Reading ip a Like a Professional

Suppose Kali shows:

lo
127.0.0.1
Enter fullscreen mode Exit fullscreen mode

Meaning:

I can talk to myself.
Enter fullscreen mode Exit fullscreen mode

Suppose Kali shows:

eth0
10.0.2.15
Enter fullscreen mode Exit fullscreen mode

Meaning:

I can reach the Internet.
Enter fullscreen mode Exit fullscreen mode

Suppose Kali shows:

eth1
192.168.56.10
Enter fullscreen mode Exit fullscreen mode

Meaning:

I can communicate with machines on my lab network.
Enter fullscreen mode Exit fullscreen mode

Once you understand what each interface is connected to, the output becomes much easier to read.


A Real Example

I started Apache on Kali.

My Kali address:

192.168.56.10
Enter fullscreen mode Exit fullscreen mode

From Windows, I opened:

http://192.168.56.10
Enter fullscreen mode Exit fullscreen mode

And immediately reached the Apache web server running inside Kali.

Why?

Because Windows and Kali were connected through the same Host-Only network.

The request traveled like this:

Windows Browser
        │
        ▼
Host-Only Network
        │
        ▼
Kali eth1
        │
        ▼
Apache
Enter fullscreen mode Exit fullscreen mode

No internet involved.

Everything happened inside a single laptop.


The Biggest Networking Mistake Beginners Make

Many people see multiple IP addresses and assume they're all the same.

They're not.

Each interface belongs to a different network.

Each network serves a different purpose.

The IP address itself is only half the story.

The interface attached to that IP matters just as much.


Final Thoughts

VirtualBox networking feels complicated at first because one machine suddenly has multiple IP addresses.

But the idea is actually simple.

Think of every interface as a separate door.

lo      = Door to yourself

eth0    = Door to the Internet

eth1    = Door to your lab network

docker0 = Door to your containers
Enter fullscreen mode Exit fullscreen mode

Once you understand what each door connects to, networking becomes much easier to visualize.

And that's the moment VirtualBox starts making sense.

Top comments (0)