Ref: Oracle VirtualBox User Guide: VirtualBox supports configurable virtual network cards per VM, host-only networking connects VMs with each other and the host while keeping them away from the outside network, and VirtualBox includes a DHCP server for host-only/internal networks. (VirtualBox) (VirtualBox)
Introduction
Oracle VirtualBox provides several networking modes for virtual machines. Each mode answers a different question:
- Should the virtual machine access the Internet?
- Should the virtual machine appear on the same network as the physical host?
- Should virtual machines communicate only with each other?
- Should the host computer be able to communicate with the virtual machines?
- Should the virtual network use static IP addresses or DHCP?
One of the most useful modes for learning, testing, development, cybersecurity labs, server labs, and isolated multi-VM environments is Host-Only Networking.
A host-only network creates a private virtual network between the host computer and one or more virtual machines. It behaves like a small private LAN inside the physical computer.
1. What Is Host-Only Networking?
Host-only networking is a VirtualBox networking mode where:
- The host computer can communicate with the virtual machine.
- Virtual machines connected to the same host-only network can communicate with each other.
- The virtual machines normally cannot access the outside physical network or the Internet through the host-only adapter alone.
- A separate virtual network interface is created on the host system.
In simple terms, host-only networking creates a private network inside your computer.
Image 1: Basic Host-Only Network
flowchart LR
H[Host Computer<br>Host-Only Adapter<br>192.168.56.1]
S[Server VM<br>192.168.56.10]
C[Client VM<br>192.168.56.20]
H --- S
H --- C
S --- C
In this diagram, the host computer and both virtual machines are connected to the same private virtual network.
2. Why Use Host-Only Networking?
Host-only networking is useful when you want a controlled and isolated environment.
Common use cases include:
Server administration labs
You can create a Windows Server VM and a client VM, then test services such as DNS, DHCP, Active Directory, file sharing, remote administration, and web hosting.
Software development
A developer can run a web server, database server, or API server inside a VM and access it from the host machine without exposing it to the outside network.
Cybersecurity practice
Host-only networking is useful when testing security tools because the traffic stays inside the host-only environment. This reduces the risk of accidentally exposing services to the real LAN.
Multi-VM application testing
A web server VM, database VM, and client VM can communicate privately, just like machines in a small internal data center.
Training and teaching
Instructors can use host-only networks to build repeatable lab environments without depending on school, office, or home network settings.
3. Main Components of Host-Only Networking
Host-only networking depends on several VirtualBox components.
3.1 VirtualBox Host-Only Network
This is the virtual network segment. It is similar to a private LAN.
Example network:
Network: 192.168.56.0/24
Subnet mask: 255.255.255.0
Usable range: 192.168.56.1 to 192.168.56.254
The exact network range can be changed.
3.2 Host-Only Adapter on the Host
VirtualBox creates a virtual network adapter on the host operating system.
On Windows, it may appear as something like:
VirtualBox Host-Only Ethernet Adapter
On Linux or macOS, the name may be different.
This adapter receives an IP address on the host-only network, such as:
192.168.56.1
That IP belongs to the host computer, not to the VM.
3.3 VM Virtual Network Adapter
Each virtual machine has one or more virtual network adapters.
Inside VirtualBox:
VM Settings → Network → Adapter 1
Attached to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter
This connects the VM to the host-only network.
3.4 VirtualBox DHCP Server
VirtualBox can run a built-in DHCP server for host-only networks. If enabled, it automatically gives IP addresses to VMs on that network.
Example:
DHCP server: 192.168.56.100
DHCP range: 192.168.56.101 - 192.168.56.254
This is convenient when you want quick automatic IP addressing.
However, if you are testing your own DHCP server inside a VM, you may want to disable VirtualBox DHCP so that your VM-based DHCP server is the only DHCP server on the private network.
3.5 VBoxManage
VBoxManage is the VirtualBox command-line management tool.
It can create, modify, list, and control networks and VM network adapters.
Example uses:
VBoxManage list hostonlyifs
VBoxManage list hostonlynets
VBoxManage list dhcpservers
VBoxManage modifyvm "VM Name" --nic1 hostonly
VBoxManage dhcpserver add ...
VBoxManage dhcpserver remove ...
The GUI is easier for beginners, but VBoxManage is powerful for automation.
4. How Host-Only Networking Works
A host-only network behaves like a virtual Ethernet switch.
The host computer and VMs connect to the same private switch.
Image 2: Host-Only Network as a Virtual Switch
flowchart TB
SW[VirtualBox Host-Only Network<br>Virtual Switch]
H[Host Adapter<br>192.168.56.1]
VM1[VM 1<br>192.168.56.10]
VM2[VM 2<br>192.168.56.20]
VM3[VM 3<br>DHCP or Static IP]
SW --- H
SW --- VM1
SW --- VM2
SW --- VM3
When VM1 pings VM2, traffic stays inside the virtual network.
When the host pings VM1, traffic goes through the host-only adapter.
When VM1 tries to access the Internet through only the host-only adapter, it normally fails because host-only networking is not designed to route traffic to the outside network by default.
5. How IP Address Assignment Works
A VM on a host-only network needs an IP address.
There are three common ways to assign IP addresses:
- Static IP address
- VirtualBox built-in DHCP
- A DHCP server running inside one of the VMs
5.1 Static IP Addressing
With static IP addressing, you manually configure the IP address inside the guest operating system.
Example:
Host-only network: 192.168.56.0/24
Host adapter: 192.168.56.1
Server VM: 192.168.56.10
Client VM: 192.168.56.20
This is simple and predictable.
Advantages
- Easy to understand
- Good for server labs
- Good when IP addresses must stay fixed
- No DHCP dependency
Disadvantages
- Manual work
- Mistakes can cause duplicate IP addresses
- Not ideal for large numbers of VMs
5.2 VirtualBox Built-In DHCP
VirtualBox can automatically assign IP addresses to VMs on host-only networks.
Example:
VirtualBox DHCP range: 192.168.56.100 - 192.168.56.200
Client VM receives: 192.168.56.101
Advantages
- Quick setup
- No need to configure IPs manually
- Useful for simple testing
Disadvantages
- Less control
- May conflict with another DHCP server
- Not ideal when learning or testing DHCP server configuration
5.3 DHCP Server Running Inside a VM
You can install a DHCP server inside a VM, such as:
- Windows Server DHCP
- Linux ISC DHCP Server
- Kea DHCP
- dnsmasq
- pfSense DHCP
- OPNsense DHCP
In this design, one VM becomes the DHCP server.
Example:
Host adapter: 192.168.56.1
DHCP Server VM: 192.168.56.10
DHCP scope/range: 192.168.56.100 - 192.168.56.150
Client VM receives: 192.168.56.100
Image 3: VM-Based DHCP Server
sequenceDiagram
participant Client as Client VM
participant Network as Host-Only Network
participant DHCP as DHCP Server VM
Client->>Network: DHCP Discover
Network->>DHCP: Broadcast reaches DHCP server
DHCP->>Client: DHCP Offer
Client->>DHCP: DHCP Request
DHCP->>Client: DHCP Acknowledge
This process is commonly called DORA:
D = Discover
O = Offer
R = Request
A = Acknowledge
Advantages
- Realistic server practice
- Good for Windows Server or Linux networking labs
- Full control over scope, lease duration, DNS options, reservations, and exclusions
Disadvantages
- More setup required
- VirtualBox DHCP should usually be disabled to avoid conflict
- Troubleshooting requires more networking knowledge
6. Static IP vs DHCP: Which Should You Use?
| Scenario | Better Choice |
|---|---|
| One or two fixed servers | Static IP |
| Quick VM testing | VirtualBox DHCP |
| Learning DHCP service configuration | VM-based DHCP |
| Active Directory domain controller | Static IP |
| Temporary client VM | DHCP |
| Firewall/router appliance lab | Static IP on router/firewall, DHCP for clients |
| Multi-VM enterprise simulation | Mix of static and DHCP |
A common design is:
Infrastructure servers: Static IP
Client machines: DHCP
For example:
DNS Server: 192.168.56.10 static
DHCP Server: 192.168.56.11 static
Web Server: 192.168.56.20 static
Client PCs: 192.168.56.100 - 192.168.56.200 via DHCP
7. Host-Only vs NAT vs Bridged vs Internal Network
VirtualBox provides multiple networking modes. Host-only is only one of them.
7.1 NAT
NAT is often the default networking mode.
The VM can access the Internet through the host, but other computers usually cannot directly access the VM unless port forwarding is configured.
Best for:
- Internet access from VM
- Simple browsing
- Software updates
- Basic VM use
7.2 Bridged Adapter
Bridged networking connects the VM directly to the physical network.
The VM behaves like another computer on the same LAN.
Best for:
- Making the VM visible to other physical computers
- Server testing on the real LAN
- Network services that must be reachable by other devices
Risk:
- The VM is exposed to the physical network.
- DHCP may come from the real router or real network DHCP server.
- Some Wi-Fi networks or corporate networks may restrict bridged VMs.
7.3 Internal Network
Internal networking allows VMs to communicate only with other VMs on the same internal network. The host is not part of the network.
Best for:
- Very isolated VM-to-VM testing
- Security labs
- Private backend networks
7.4 Host-Only Network
Host-only networking allows communication between the host and VMs, and between VMs on the same host-only network.
Best for:
- Labs
- Development
- Server testing
- Private VM networks where the host still needs access
Image 4: Networking Mode Comparison
flowchart TD
A[VirtualBox Networking Modes]
A --> NAT[NAT<br>VM to Internet through host]
A --> BR[Bridged<br>VM joins physical LAN]
A --> INT[Internal Network<br>VM-to-VM only]
A --> HO[Host-Only<br>Host-to-VM and VM-to-VM]
NAT --> N1[Good for Internet access]
BR --> B1[Good for real LAN visibility]
INT --> I1[Good for isolated VM networks]
HO --> H1[Good for private labs and development]
8. When to Use Multiple Network Adapters
A VM can have more than one network adapter.
For example:
Adapter 1: NAT
Adapter 2: Host-only
This gives the VM:
- Internet access through NAT
- Private communication with the host and other VMs through host-only
Example design
Web Server VM
Adapter 1: NAT → Internet updates
Adapter 2: Host-only → Private lab network
Image 5: Dual-Adapter VM
flowchart LR
Internet[Internet]
Host[Host Computer]
VM[Virtual Machine<br>Adapter 1: NAT<br>Adapter 2: Host-only]
Private[Host-Only Network<br>Private Lab LAN]
VM --> Internet
Host --- Private
Private --- VM
This setup is useful when you need Internet access but also want an isolated lab network.
9. Creating a Host-Only Network in the VirtualBox GUI
The exact menu names can vary slightly by version and operating system, but the general process is:
- Open VirtualBox Manager.
- Go to Tools or File → Tools.
- Open Network Manager.
- Find the Host-Only Networks section.
- Create a new host-only network.
- Configure the IPv4 address and subnet mask.
- Decide whether to enable or disable the VirtualBox DHCP server.
- Open the VM settings.
- Go to Network.
- Enable a network adapter.
- Set “Attached to” as Host-only Adapter or Host-only Network.
- Select the host-only network name.
- Start the VM and configure IP settings inside the guest OS.
Example host-only network configuration:
IPv4 address: 192.168.56.1
IPv4 mask: 255.255.255.0
DHCP: enabled or disabled depending on your purpose
10. Creating or Managing Host-Only Networks with VBoxManage
VBoxManage can be used instead of the GUI.
Useful commands include:
VBoxManage list hostonlyifs
VBoxManage list hostonlynets
VBoxManage list dhcpservers
To configure a VM adapter:
VBoxManage modifyvm "MyVM" --nic1 hostonly
Depending on the VirtualBox version and host platform, host-only networks and host-only interfaces may be managed with commands such as:
VBoxManage hostonlynet add
VBoxManage hostonlynet modify
VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig
To manage the built-in DHCP server:
VBoxManage dhcpserver add
VBoxManage dhcpserver modify
VBoxManage dhcpserver remove
VBoxManage dhcpserver start
VBoxManage dhcpserver stop
VBoxManage dhcpserver findlease
The GUI is usually easier for beginners. The command line is better for repeatable lab setup and automation.
11. Should VirtualBox DHCP Be Enabled or Disabled?
It depends on what you want to achieve.
Enable VirtualBox DHCP when:
- You want quick automatic IP addresses.
- You do not care which DHCP server gives the address.
- You are not testing DHCP server configuration.
- You want a simple private network with minimal setup.
Disable VirtualBox DHCP when:
- You are testing your own DHCP server.
- You want to manually assign static IP addresses.
- You want to avoid DHCP conflicts.
- You need predictable IP addressing.
- You are simulating enterprise DHCP behavior.
A good rule:
If the purpose is convenience, VirtualBox DHCP is fine.
If the purpose is learning or testing DHCP, disable VirtualBox DHCP and use your own DHCP server.
12. How to Verify IP Addressing
Inside a Windows guest:
ipconfig /all
Inside a Linux guest:
ip addr
ip route
cat /etc/resolv.conf
From one VM to another:
ping 192.168.56.10
From Windows PowerShell:
Test-Connection 192.168.56.10
Things to check:
IP address
Subnet mask
Default gateway
DNS server
DHCP enabled or disabled
DHCP server address
MAC address
13. Common Host-Only Network Problems
Problem 1: VM gets 169.254.x.x address
A 169.254.x.x address usually means the VM tried to use DHCP but did not receive a response.
Possible causes:
- DHCP server is disabled.
- DHCP server is not reachable.
- VM is connected to the wrong adapter.
- Network cable option is unchecked.
- Firewall is blocking traffic.
- DHCP scope is misconfigured.
Problem 2: VM cannot ping another VM
Check:
- Are both VMs on the same host-only network?
- Are both VMs in the same IP subnet?
- Is the firewall blocking ping?
- Is the VM network adapter enabled?
- Is the virtual cable connected?
Problem 3: VM gets IP from wrong DHCP server
This can happen if multiple DHCP servers exist on the same network.
Check the DHCP server line:
ipconfig /all
If the DHCP server is not the one you expected, disable the unwanted DHCP server or move the VM to a different virtual network.
Problem 4: Host cannot reach VM
Check:
- Host-only adapter exists on the host.
- Host-only adapter has the correct IP address.
- VM is connected to the same host-only network.
- Guest firewall allows the required traffic.
- VM IP address is in the same subnet as the host-only adapter.
14. Practical Design Examples
Example 1: Simple Host-to-VM Development
Host: 192.168.56.1
Web VM: 192.168.56.10
Database: 192.168.56.20
The host browser can open:
http://192.168.56.10
The web VM can connect to the database VM privately.
Example 2: Server and Client Lab
Server VM: 192.168.56.10 static
Client VM: 192.168.56.20 static or DHCP
Host: 192.168.56.1
This is useful for practicing DNS, DHCP, file sharing, remote management, and web services.
Example 3: Dual-Network Server
Adapter 1: NAT
Adapter 2: Host-only
The VM uses NAT for updates and host-only networking for private lab communication.
Example 4: Firewall/Router Lab
Firewall VM
Adapter 1: NAT or Bridged
Adapter 2: Host-only
Client VM
Adapter 1: Host-only
The firewall VM can act as a router between the private host-only network and another network.
15. Security Considerations
Host-only networking is safer than bridged networking for many lab situations because the VM is not automatically exposed to the physical LAN.
However, it is not the same as perfect security.
Remember:
- The host can communicate with the VMs.
- VMs on the same host-only network can communicate with each other.
- Services inside VMs may still be reachable from the host.
- A dual-adapter VM may connect the private network to another network if routing is enabled.
- Firewalls inside the guest operating system still matter.
For sensitive testing, use snapshots and isolated networks carefully.
16. Best Practices
Use static IP addresses for infrastructure machines:
DNS servers
DHCP servers
Domain controllers
Routers
Firewalls
Database servers
Use DHCP for client machines:
Desktop clients
Test clients
Temporary VMs
Use separate host-only networks for separate labs:
Lab A: 192.168.56.0/24
Lab B: 192.168.57.0/24
Lab C: 192.168.58.0/24
Avoid running multiple DHCP servers on the same virtual network unless you are intentionally testing that scenario.
Document your network:
Network name
Subnet
Host adapter IP
DHCP range
Static server IPs
Gateway
DNS server
VM adapter mode
Conclusion
Host-only networking in Oracle VirtualBox is one of the most useful networking modes for building private virtual labs. It gives the host and virtual machines a shared private network while keeping the VMs isolated from the outside network by default.
IP addressing can be handled manually with static addresses, automatically through VirtualBox DHCP, or through a DHCP server running inside a virtual machine. The best choice depends on the purpose of the environment.
For quick testing, VirtualBox DHCP is convenient. For server administration, networking, and enterprise simulation, static IP addresses and a VM-based DHCP server provide more control and realism.
A good host-only network design is simple, documented, and intentional. Decide which machines need static IPs, which machines should use DHCP, whether Internet access is needed, and whether the host should be able to access the services inside the VMs.
Ref: AI Tools, ChatGPT
