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 UpUse 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 secondsBasic network understandingWhen 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
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.
-
Use Adapter 1: NAT → for internet access
-
Use Adapter 2: Host-only → for static IP and host-to-VM communication
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 secondsAs a result, we now see two new IP addresses in the list of active devices.






Comments
Post a Comment