Configuring Ubuntu 24.04 VM Internet Connection through Hyper-V External Switch
Hyper-V is a powerful virtualization platform built into Windows 11. In this article, we will walk you through the process of configuring an Ubuntu 24.04 virtual machine to connect to the internet using a Hyper-V External Switch. This configuration is particularly useful for scenarios where you want to create a paired connection between your host and virtual machine, sharing the same network interface card (NIC).
Prerequisites
Before getting started, you need to ensure the following:
- A Windows 11 host with Hyper-V enabled.
- A virtual machine (VM) with Ubuntu 24.04 installed.
- A network interface card (NIC) configured for sharing, allowing external switch creation.
Creating a Hyper-V External Switch
To create an external switch, perform the following steps:
- Launch the Hyper-V Manager on your Windows 11 host.
- In the Actions pane, click on
Virtual Switch Manager. - In the Virtual Switch Manager dialog, click on
New virtual network switch. - Choose
Externaland clickCreate virtual switch. - Name the virtual switch and select the NIC to share from the drop-down menu.
- Click
OKto create the external switch.
Configuring Ubuntu VM Network Settings
To set up internet connectivity on your Ubuntu VM, follow these steps:
- Power on the Ubuntu VM and log in.
- Open the terminal and type
ifconfigto check the current network configuration. - Edit the
/etc/netplan/01-netcfg.yamlfile by using a text editor like nano or vi: - In the file, replace the existing content with the following:
- Save and exit the file.
- Apply the network configuration by using the following command:
- Check the network configuration again by running
ifconfig.
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
enp0s3:
dhcp4: yes
sudo netplan apply
Troubleshooting - Lost Internet Connection on External Switch
If you lose internet connectivity after changing the NIC to an external switch, follow these steps:
- Check if the host has internet connectivity. If not, reconfigure your host's network settings.
- Verify the external switch settings within Hyper-V manager.
- Power off the VM, then edit the VM settings and ensure that the network adapter is connected to the correct external switch.
- Restart the VM to apply the changes.
In this article, we discussed configuring an Ubuntu 24.04 virtual machine to connect to the internet via a Hyper-V External Switch. We covered the following key concepts:
- Creating a Hyper-V External Switch
- Configuring Ubuntu VM network settings
- Troubleshooting lost internet connectivity after changing to an external switch
References
-
Type: Article
Title: "Configure a Hyper-V virtual switch for virtual machines in Windows Server"
URL: https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/get-started/create-a-virtual-switch-for-virtual-machines -
Type: Book
Title: "Mastering Hyper-V Virtualization and Security"
Author: Yuri Diogenes, James Pennino, Murat Anavar, Devi Arjuna, and Debra Littlejohn Shinder
Publisher: Packt Publishing, 2018
ISBN: 978-1788474171 -
Type: Online Resource
Title: "Ubuntu 24.04 Server Guide"
URL: https://ubuntu.com/server/docs/network-configuration