NIC Change VM (Ubuntu Hyper-V) Default Switch

Abstract: Fix lost internet in Ubuntu Hyper-V VM after switching to external network adapter by correcting Netplan configuration and verifying host switch binding.

Created: 2026-07-30 by
Switching the network adapter in an Ubuntu Hyper-V VM from a default switch to an external switch often breaks connectivity because the guest operating system does not automatically update its network configuration files. The issue stems from static definitions that reference the old interface name or IP settings which no longer match the new virtual hardware profile. Restoring access requires manually correcting the Netplan configuration to reflect the new NIC identifier and ensuring the Hyper-V switch is properly bound to a physical uplink.

Understanding the Root Cause

When you change the Virtual Machine Network Adapter settings in Hyper-V Manager, the underlying hardware presented to the Ubuntu guest changes. If the previous connection relied on the "Default Switch" (a NAT-based internal network), the DHCP client likely obtained an IP address dynamically. However, many Ubuntu installations use netplan with YAML configuration files that may contain static IP assignments or hardcoded gateway entries tied to the previous interface state. Furthermore, Hyper-V's "External Switch" requires a direct binding to a physical network interface card (NIC) on the host machine. If this binding is missing or incorrect, the VM has no path to the outside world. Unlike the Default Switch, which handles NAT transparently, an External Switch acts as if the VM were plugged directly into your physical LAN. Therefore, the OS must be configured to obtain an IP address via DHCP from your actual router, or you must manually assign a static IP that exists within your local subnet range.

Verifying Hyper-V Switch Configuration

Before modifying the Linux guest, ensure the host-side configuration is correct. Open Hyper-V Manager on your Windows host. Navigate to Virtual Switch Manager. You should see a switch type set to External. Select it and verify that the checkbox for "Allow management operating system to share this network adapter" is checked if you need the host to retain internet access. More importantly, ensure the specific physical NIC that provides your internet connection is selected in the dropdown menu. If this is unselected, the virtual switch is effectively disconnected from the physical network, regardless of what the guest OS attempts to do. After confirming the switch settings, restart the virtual machine. This ensures the new virtual hardware profile is loaded correctly by the hypervisor.

Diagnosing the Guest Network Interface

Once Ubuntu boots, log in via the console or SSH if possible. The first step is to identify the current network interface name. In modern Linux distributions, interface names are dynamic. Run the following command:
ip link show
Look for an interface that is in the UP state but has no IP address assigned, or one that shows a carrier signal. Common names include eth0, ens3, or enp0s5. Note this exact name. If you previously used a static configuration file referencing eth0 but the system now identifies the card as ens3, the configuration will fail to apply. Check the current status of the interface using:
ip addr show <interface_name>
If the output shows no IPv4 address, the DHCP client has failed to communicate with the router. This confirms that the issue is either a misconfiguration in Netplan or a lack of physical connectivity from the Hyper-V side.

Correcting Netplan Configuration

Ubuntu uses netplan to manage networking. The configuration files are typically located in /etc/netplan/. List the files in this directory:
ls /etc/netplan/
Open the primary YAML file (often named something like 01-netcfg.yaml or 50-cloud-init.yaml) using a text editor such as nano or vim:
sudo nano /etc/netplan/01-netcfg.yaml
You must ensure two critical things in this file. First, the match section must correspond to the interface name you identified earlier. Second, you should generally use DHCP for external switches unless you have a specific static IP requirement. Avoid using deprecated keywords like gateway4, which are ignored in newer versions of Netplan and can cause silent failures. Instead, use the modern syntax. A correct, robust configuration for a DHCP-enabled external switch looks like this:
network:
  version: 2
  ethernets:
    ens3:          # Replace with your actual interface name
      dhcp4: true
      dhcp6: false
Ensure there is proper indentation. YAML is whitespace-sensitive. If you had previous static entries, remove them. If you specifically need a static IP, you must include the routes section instead of dhcp4, specifying the correct gateway IP for your local network. Apply the changes with:
sudo netplan apply
If the command returns an error, check the syntax carefully. If it succeeds silently, test connectivity by pinging a public DNS server:
ping 8.8.8.8
If ping fails, check the routing table with ip route show. If no default route exists, the DHCP lease was not obtained. Re-check the Hyper-V switch binding.

Alternative Troubleshooting Steps

If the standard Netplan fix does not resolve the issue, consider checking the firewall settings on the Ubuntu guest. Sometimes, switching networks triggers UFW (Uncomplicated Firewall) rules that block incoming traffic. Temporarily disable the firewall to test:
sudo ufw disable
If connectivity returns, re-enable it and configure appropriate rules. Additionally, verify that the Hyper-V integration services are installed and running, as these provide optimized drivers for network and time synchronization. For more complex scenarios involving hybrid setups where you need to balance host and guest access, refer to our guide on Hyper-V: Accessing LAN Devices on Host. This resource details how to configure VLANs and advanced switch properties that might interfere with basic external connectivity. Another common pitfall occurs when users attempt to force static IPs without understanding their local subnet mask. If you are unsure about the correct gateway address for your home or office network, consult your router's admin page or use the host machine's ipconfig (on Windows) to find the default gateway, then mirror that value in your Netplan config.

Frequently Asked Questions

Why did my internet work on Default Switch but not External?

The Default Switch uses NAT and handles IP assignment internally, requiring minimal guest configuration. An External Switch connects directly to your physical network, meaning the guest must behave like any other device on your LAN, relying on your physical router for IP addresses and routing.

Can I use a static IP with an External Switch?

Yes, but you must manually calculate the correct IP, subnet mask, and gateway based on your local network. Using the wrong gateway address will result in no internet access even if the interface is UP.

What if netplan apply says 'invalid configuration'?

This usually indicates a YAML syntax error, such as incorrect indentation or a typo in the interface name. Use yamllint or carefully compare your file against a known-good template to spot spacing issues.

Does changing the switch affect my SSH keys?

No, SSH keys are stored on the disk and are independent of network interfaces. However, if your SSH server is configured to listen only on a specific IP, you may need to update that configuration after the switch change.

How do I revert to the Default Switch?

In Hyper-V Manager, delete the External Switch binding from the VM's network adapter settings and select "Default Switch" from the dropdown. Then reboot the VM. The guest will automatically reconfigure via DHCP for the NAT environment.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More