To configure network settings inside an Ubuntu virtual machine running in VirtualBox, you must first ensure the virtual machine is powered off to modify hardware-level network adapters. Then, access the VM’s Settings via the VirtualBox Manager, select the Network tab, and choose the appropriate Adapter type such as NAT for internet access or Bridged Adapter for direct LAN connectivity.
Preparing the Virtual Machine
Before making any changes to the network configuration, it is critical that the Ubuntu virtual machine is completely shut down. You cannot modify network adapter settings while the guest operating system is running because these are considered hardware properties managed by the hypervisor. If you attempt to change settings while the VM is active, VirtualBox will either ignore the changes or require a restart of the network service within the guest, which can lead to unstable connections.
Navigate to your VirtualBox Manager interface. Locate your Ubuntu instance in the list of virtual machines on the left sidebar. Right-click on the specific VM and select "Settings" from the context menu. Alternatively, you can click the gear icon in the toolbar if the VM is selected. This opens the global settings window for that specific machine. Ensure you do not confuse this with the general VirtualBox application preferences; you need the per-VM settings.
Selecting the Network Adapter Type
The core of configuring network settings lies in selecting the correct adapter mode. In the Settings window, navigate to the "Network" tab. The first tab labeled "Adapter 1" is enabled by default. Here you will find the "Attached to" dropdown menu, which determines how the VM connects to the host network.
NAT (Network Address Translation) is the default and most common setting. It allows the VM to access the internet through the host machine’s IP address. The VM appears as a device behind the host router. This is ideal for general browsing, software updates, and downloading packages where you do not need other devices on your local network to see the VM.
Bridged Adapter connects the VM directly to your physical network interface. The VM obtains its own IP address from your local router, just like a physical computer plugged into the same switch. This is necessary if you need to SSH into the VM from another computer on your LAN or if you are hosting a web server accessible to other local users. Note that bridging requires the host’s network driver to support promiscuous mode.
Internal Network creates a private network between VMs only. No external traffic can pass through this adapter. This is useful for isolated testing environments where security is paramount.
NAT Network provides a more advanced version of NAT, allowing multiple VMs to communicate with each other and the host while sharing a single IP for outbound traffic.
Configuring Advanced Network Options
Once the adapter type is selected, you may need to adjust additional parameters. Click the "Advanced" section at the bottom of the Network tab. Here you can set the MAC address. While usually auto-generated, manually setting a static MAC address can prevent conflicts if you clone the VM. If you change the MAC address, be aware that this may disable internet access until the new address is recognized by the DHCP server, a process detailed in our guide on
Ubuntu 20.04 on VirtualBox: Missing Internet Access after Changing MAC Address.
You can also enable "Cable Connected" to simulate a physical cable plug. If this box is unchecked, the OS will detect no network link. For most configurations, leave this checked. If you are experiencing issues with connectivity, check the "Promiscuous Mode" setting. Set it to "Allow All" if you are using bridged networking and suspect packet filtering issues, though this has security implications.
Verifying Configuration in Ubuntu
After saving the settings in VirtualBox, power on the Ubuntu VM. Once the desktop loads, open a terminal. Use the command
ip addr show or
ifconfig to view the assigned IP addresses. If you selected NAT, you should see an interface with an IP in the 10.0.2.x range. If you selected Bridged, you should see an IP assigned by your local router, typically starting with 192.168.x.x or 10.0.1.x.
Test connectivity by pinging an external site, such as
ping 8.8.8.8. If this fails, check your DNS resolution with
nslookup google.com. If ping works but domain names fail, your
/etc/resolv.conf file may need updating. If you are trying to route traffic between VMs, refer to
How to Configure a Traffic Route from VM1 through Host to VM2 for routing table adjustments.
Troubleshooting Common Issues
If the VM shows "Network Cable Unplugged," verify that the "Cable Connected" checkbox is ticked in the VirtualBox settings. Restart the networking service within Ubuntu using
sudo systemctl restart networking or reboot the VM entirely.
For Bridged Adapter issues, ensure that the host’s Wi-Fi or Ethernet driver supports bridging. Some modern Wi-Fi drivers have limitations with bridging. If you cannot get a bridged connection, try switching to NAT Network or using port forwarding rules in the NAT settings to map host ports to guest ports.
If you encounter permission errors during setup, especially when using Vagrant with VirtualBox, check your user permissions. Errors often stem from incorrect group memberships or SELinux policies. See
Fixing Permission Denied Error in Vagrant with Ubuntu Jammy64 for solutions to related permission blocks.
Frequently Asked Questions
Why can't I see my Ubuntu VM on the local network?
This usually happens because the adapter is set to NAT instead of Bridged. NAT hides the VM behind the host's IP, making it invisible to other LAN devices. Switching to Bridged Adapter assigns a unique IP to the VM, allowing it to appear as a separate device on your network.
How do I assign a static IP to my Ubuntu VM?
You can configure a static IP by editing the Netplan configuration files in
/etc/netplan/. Identify your network interface name using
ip link, then create a YAML file specifying the desired IP address, gateway, and DNS servers. Apply the changes with
sudo netplan apply.
What is the difference between NAT and NAT Network?
NAT allows individual VMs to access the internet but isolates them from each other unless port forwarding is configured. NAT Network creates a shared subnet where all VMs in the network can communicate directly with each other and the host, while still sharing a single external IP for outbound traffic.
Can I use two network adapters simultaneously?
Yes, VirtualBox allows you to enable up to four network adapters. You can attach one adapter to NAT for internet access and another to Bridged for local LAN communication. Each adapter operates independently and can have different settings.
Why does my VM lose internet access after cloning?
Cloning a VM often generates a new MAC address. If the DHCP server on your network has cached the old MAC address, it may not assign a new IP correctly. Refreshing the network lease by restarting the network manager or renewing the DHCP request usually resolves this issue.