Standalone Ubuntu 20.04 LTS on Hyper-V: No Ethernet Connection
Ubuntu 20.04 LTS is a popular Linux distribution known for its stability and ease of use. Running Ubuntu 20.04 LTS as a standalone virtual machine on Hyper-V can be an excellent way to create a separate, isolated environment for testing, development, or other purposes. However, some users might find that their Ubuntu 20.04 LTS virtual machine on Hyper-V does not have an Ethernet connection, making it impossible to access the internet or network resources.
Prerequisites
Before we begin, ensure you have the following:
- A host machine running Windows 10 Pro or Enterprise with Hyper-V enabled.
- An Ubuntu 20.04 LTS ISO file.
- Basic knowledge of Hyper-V and Ubuntu.
Creating a Standalone Ubuntu 20.04 LTS Virtual Machine on Hyper-V
First, create a new virtual machine in Hyper-V with the following configuration:
- Generation: Version 2
- Memory: 2048 MB
- Network: Not connected
- Hard Disk: Dynamically expanding, 40 GB
After creating the virtual machine, mount the Ubuntu 20.04 LTS ISO file as the virtual DVD drive, and start the virtual machine. Follow the installation prompts to install Ubuntu 20.04 LTS on the virtual machine.
Configuring the Ethernet Connection
After installing Ubuntu 20.04 LTS, you might notice that there is no Ethernet connection. This issue occurs because the virtual switch created by default in Hyper-V does not support the legacy network adapter required by Ubuntu 20.04 LTS.
To resolve this issue, follow these steps:
- Shut down the Ubuntu 20.04 LTS virtual machine.
- Create a new virtual switch in Hyper-V with the following configuration:
- Name: External
- Type: External network
- Shared with: Your host machine
- Start the Ubuntu 20.04 LTS virtual machine and log in.
- Open the terminal and run the following command:
- Find the following lines:
- Apply the new network configuration by running the following command:
sudo nano /etc/netplan/01-netcfg.yaml
This command opens the network configuration file in the nano text editor.
network:
version: 2
ethernets:
Below the "ethernets" line, add the following lines:
enp0s8:
dhcp4: yes
The resulting configuration should look like this:
network:
version: 2
ethernets:
enp0s8:
dhcp4: yes
Save and close the file by pressing Ctrl+X, then Y, and then Enter.
sudo netplan apply -
After running this command, you should have a working Ethernet connection in your Ubuntu 20.04 LTS virtual machine.
In this article, we discussed how to create a standalone Ubuntu 20.04 LTS virtual machine on Hyper-V and configure the Ethernet connection. By default, the virtual switch created by Hyper-V does not support the legacy network adapter required by Ubuntu 20.04 LTS. To resolve this issue, we created a new virtual switch with the "External" type and shared it with the host machine. Then, we modified the network configuration file in Ubuntu 20.04 LTS to enable DHCP on the virtual Ethernet adapter.