Skip to main content

VirtualBox Networking Made Easy: Assign a Static IP to Your VM

 

In this post, I’ll show how to assign a static IP address to a Linux virtual machine running in Oracle VirtualBox. The steps include checking the current network setup on the host machine, identifying which IP ranges are safe to use, and using the nmap tool to scan for available IPs. I’ll then walk through configuring the network settings in VirtualBox, choosing between Host-only and Bridged Adapter modes, and applying a static IP inside the Linux VM. This setup makes it easy to connect to the VM from the host using SSH tools like PuTTY or MobaXterm.

Current network setup 

Taking a look the ipconfig output on windows, we can quickly see our setup.
In my case we have 2 network adapters, one is obviously my real network and second one is the VirtualBox adapter.

 

Another way to confirm which is the VirutalBox adapter is to open the Oracle Virtual Box → File → Tools → Network Manager

 

or you could use PowerShell as well.


PS C:\Users\meris> Get-NetAdapter | Select-Object Name, InterfaceDescription, Status

Name       InterfaceDescription                                      Status
----       --------------------                                      ------
Ethernet   Realtek USB GbE Family Controller                         Up
Ethernet 3 Cisco AnyConnect Virtual Miniport Adapter for Windows x64 Disabled
Ethernet 2 Intel(R) I211 Gigabit Network Connection                  Disconnected
Ethernet 4 VirtualBox Host-Only Ethernet Adapter                     Up

Use Nmap to scan the network and identify any active IP addresses. If this is a fresh installation, the only active IP should be the gateway at 192.168.56.1.

C:\Users\meris>nmap -sn 192.168.56.0/24
Starting Nmap 7.97 ( https://nmap.org ) at 2025-06-08 19:04 +0200
Nmap scan report for 192.168.56.1
Host is up.
Nmap done: 256 IP addresses (1 host up) scanned in 36.98 seconds
Basic network understanding

When working with IP addressing in networking, you’ll often come across something like this:
192.168.56.0/24. This is known as CIDR notation (Classless Inter-Domain Routing), and it helps define the size of a network.

This format breaks down into two parts:

  • 192.168.56.0 – This is the network address, the starting point of the subnet.

  • /24 – This tells us how many bits are used for the network portion of the IP address. In this case, it’s 24 out of 32 bits.

How to calculate usable IP addresses:

Every IPv4 address is 32 bits long. The /24 means 24 of those bits are used for the network, leaving the rest for hosts (devices like computers or virtual machines).

To find the number of bits available for hosts:

Host bits = 32 - 24 = 8 bits

However, 2 addresses are reserved — typically the first address (ending in .0) as the network identifier, and the last address (ending in .255) as the broadcast address.
This leaves us with 254 usable IP addresses within the subnet.

In our case, the usable IP range extends from 192.168.56.2 to 192.168.56.254. Since 192.168.56.1 is already reserved as the gateway, the rest of the addresses in this range can be assigned to other virtual machines.

Linux VM Setup with Static IP – A Practical Walkthrough 




VirtualBox Networking Simplified: NAT vs Host-Only

When you create a virtual machine in VirtualBox, one important step is deciding how it connects to your network. This determines whether your VM can access the internet, your host machine, or both. The two most common options are NAT and Host-only networking.

NAT stands for Network Address Translation. When you use NAT in VirtualBox:

  • Your VM shares the host’s internet connection.

  • The VM can go online (update packages, browse, etc.).

  • But you can’t connect to the VM directly from your host — for example, no ping or SSH without port forwarding.  

Host-only networking creates a private network between your host and the VM.

  • Your host gets an IP (e.g. 192.168.56.1 => our gateway)

  • Your VM gets another (e.g. 192.168.56.10 => we can assign the IP if not used)

  • You can connect to the VM from the host — ping, SSH, ... — but there’s no internet unless you add another adapter e.g. NAT.


Our configuration includes two network adapters: one set to NAT for internet access, and one set to Host-Only for communication between the host and the VM.
  • Use Adapter 1: NAT → for internet access

  • Use Adapter 2: Host-only → for static IP and host-to-VM communication


I installed Oracle Linux 8 and assigned a static IP address during the installation. If you're using a different OS, like Windows, you can also set a static IP later through the Network Adapter settings.
 
Linux network config of my VM

enp0s3 → NAT 
enp0s8 → Host-only 

[root@server-graz ~]# ip a
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:37:d7:ee brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
       valid_lft 79580sec preferred_lft 79580sec
    inet6 fd17:625c:f037:2:a00:27ff:fe37:d7ee/64 scope global dynamic noprefixroute
       valid_lft 86311sec preferred_lft 14311sec
    inet6 fe80::a00:27ff:fe37:d7ee/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: enp0s8:  mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:93:47:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.10/24 brd 192.168.56.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe93:47fc/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
As a final step, I used nmap to scan the network and see which IP addresses are currently in use.
nmap -sn 192.168.56.0/24
Starting Nmap 7.97 ( https://nmap.org ) at 2025-06-08 22:30 +0200
Nmap scan report for 192.168.56.10
Host is up (0.00s latency).
MAC Address: 08:00:27:93:47:FC (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.56.100
Host is up (0.00s latency).
MAC Address: 08:00:27:C3:68:92 (Oracle VirtualBox virtual NIC)
Nmap scan report for 192.168.56.1
Host is up.
Nmap done: 256 IP addresses (3 hosts up) scanned in 48.06 seconds
As a result, we now see two new IP addresses in the list of active devices.

Comments

Popular posts from this blog

In-Place Upgrade from Oracle Linux 7 to 8 Using LEAPP

Upgrading from Oracle Linux 7 to Oracle Linux 8 is important to keep your system secure, stable, and supported. Oracle Linux 7 is now out of support, which means it no longer receives updates, security patches, or fixes. Moving to Oracle Linux 8 ensures you continue getting updates, new features, and better performance. The LEAPP tool makes this upgrade easier by allowing an in-place upgrade, so you don’t need to reinstall the system from scratch. It checks if your system is ready, identifies potential issues, and helps guide you through the upgrade process. This guide will walk you through the basic steps and requirements to successfully upgrade Oracle Linux 7 to Oracle Linux 8 using LEAPP. Oracle Lifetime Support Policy Regarding upgrading Oracle Linux 7 to Oracle Linux 8, here are a few key points to consider: Review the official documentation thoroughly before starting the upgrade process Ensure you have a complete backup in place, as this is an in-place upgrade and you may n...

Step-by-Step Guide to Renewing OLVM Certificates in Version 4.3

Managing certificates is a critical administrative task in Oracle Linux Virtualization Manager (OLVM) environments, as expired certificates can result in host disconnections, authentication failures, and service disruptions. In this article, we will cover the process of renewing certificates in OLVM version 4.3 before they expire, ensuring secure communication between the engine and managed KVM hosts. For this procedure, we will use the OlvmKvmCerts utility provided by Oracle to renew the required certificates. In OLVM 4.3, although some engine-related certificates can be renewed using the engine-setup command, not all certificates are automatically refreshed. Certain components require manual renewal because the certificate renewal process in this version is not fully automated. It is important to note that this limitation has been addressed in  OLVM 4.4.10.7-1.0.24 and later.  Additionally, OLVM 4.3 has been unsupported since October 2022, and OLVM 4.4 reached end of su...

Oracle 19c: Data Guard Physical Standby Setup Guide

In this blog post, we’ll walk through the process of creating a Data Guard Physical Standby database in Oracle Database 19c, where ASM (Automatic Storage Management) and OMF (Oracle Managed Files) are used for storage management.  Setting up a standby database with Data Guard enhances the high availability, disaster recovery, and data protection capabilities of your Oracle environment.  By leveraging ASM and OMF, we simplify file management and ensure optimal performance and flexibility. This guide provides a step-by-step approach, from preparing the primary database to configuring the standby environment, ensuring a smooth and reliable setup. Environment Overview In this setup, we have two database servers configured for a Data Guard Physical Standby environment: Primary Server : server-graz – This server hosts the primary database named graz . Standby Server : server-salzburg – This server will act as the physical standby. Both servers are configured to use ASM (Au...