A deep dive into configuring Internal Networks in Virtual Machines
learning how to virtualize again
November 24, 2024 (Updated: November 24, 2024)
In this post we’ll be looking at networking the virtual machines we made in the last post
Prerequisites
Software Needed
- Hypervisor Software: in this guide i used Oracle VirtualBox but there are other software such as VMwareWorkstation or Proxmox
- ISO Files: all can be found on their respective sites 1
- EndeavourOS
- Fedora Desktop
- Ubuntu Desktop
- Ubuntu Live Server
- Hardware Requirements:
- At least 8 GB of RAM
- 20 GB of disk sapce per virtual machine
- Processor with virtualisation support
Network Configuration
Host-Only Adapter
- Name: Example Adapter
- IPv4 Address:
192.168.32.1
- Subnet Mask:
255.255.255.0
NAT Adapter (for Internet Access)
- This adapter will be used to provide internet access to the virtual machines.
Step 1: Configure the Host-Only Adapter
In VirtualBox:
- Open VirtualBox and go to File > Host Network Manager.
- Click Create to add a new host-only adapter.
- Set the adapter’s details:
- IPv4 Address:
192.168.32.1
- Subnet Mask:
255.255.255.0
- IPv4 Address:
- Ensure DHCP Server is disabled to manually assign IP addresses.
- Save the settings.
Step 2: Attach Virtual Machines to the Internal Network
- Open the settings for each virtual machine
- Go to the Network section.
- Set Adapter 1 to:
- Attached to: Host-Only Adapter
- Name: Example Adapter
- Add Adapter 2 : Attached to : NAT
- Save the settings
Step 3: Assign Static IP Addresses
General Network Details
- Gateway:
192.168.32.1
- Subnet Mask:
255.255.255.0
- IP Ranges:
- Fedora:
192.168.32.10
- EndeavourOS:
192.168.32.20
- Ubuntu Desktop:
192.168.32.30
- Ubuntu Live Server:
192.168.32.40
- Fedora:
Fedora
- Open the terminal and edit the network configuration file:
bash sudo nano /etc/sysconfig/network-scripts/ifcfg-ens33
- Add or modify the following lines:
bash BOOTPROTO=none IPADDR=192.168.32.10 NETMASK=255.255.255.0 GATEWAY=192.168.32.1 DNS1=8.8.8.8
- Restart the network service:
sudo systemctl restart NetworkManager
EndeavourOS
- Edit the network configuration:
bash sudo nano /etc/systemd/network/20-wired.network
- Add the following:
bash [Match] Name=ens33 [Network] Address=192.168.32.20/24 Gateway=192.168.32.1 DNS=8.8.8.8
- Restart the network service:
bash sudo systemctl restart systemd-networkd
Ubuntu Desktop
- Edit the Netplan configuration file:
bash sudo nano /etc/netplan/01-netcfg.yaml
- Add the following configuration:
network: version: 2 renderer: networkd ethernets: ens33: dhcp4: no addresses: - 192.168.32.30/24 gateway4: 192.168.32.1 nameservers: addresses: [8.8.8.8]
- Apply the configuration:
bash sudo netplan apply
Ubuntu Live Server
- Edit the Netplan configuration file:
bash sudo nano /etc/netplan/01-netcfg.yaml
- Add the following:
network: version: 2 renderer: networkd ethernets: ens33: dhcp4: no addresses: - 192.168.32.40/24 gateway4: 192.168.32.1 nameservers: addresses: [8.8.8.8]
- Apply the configuration:
bash sudo netplan apply
Step 4: Test Connectivity
-
Ping the Gateway: From each VM, test the connection to the gateway:
bash ping 192.168.32.1
-
Ping Between VMs: Test communication between the VMs:
bash ping 192.168.32.20 # From Fedora to EndeavourOS ping 192.168.32.30 # From EndeavourOS to Ubuntu Desktop
-
Test Internet Access: From each VM, check internet connectivity:
bash ping google.com
Step 5: Troubleshooting Common Issues
- VMs cannot communicate with each other on the internal network
- Ensure all VMs are connected to the same Host-Only Adapter and the adapter name matches across the configurations.
- VMs cannot reach the internet through the NAT adapter
- Check that the NAT adapter is correctly added as a second adapter in the VM settings. Verify that the NAT network is active in VirtualBox.
- IP conflicts between VMs on the internal network
- Double-check the static IP configurations and ensure each VM has a unique IP address.