Skip to content

Instantly share code, notes, and snippets.

@uarun
Created June 21, 2026 00:44
Show Gist options
  • Select an option

  • Save uarun/88f87264526f69aa1dcf927ff8627e57 to your computer and use it in GitHub Desktop.

Select an option

Save uarun/88f87264526f69aa1dcf927ff8627e57 to your computer and use it in GitHub Desktop.
Hyper-V VM Networking Setup (External Switch)

Hyper-V VM Networking Setup (External Switch)

The Default Switch (Internal + ICS) is unreliable — Windows Updates frequently break the SharedAccess service that provides NAT/DHCP. Use an External Switch instead.

Prerequisites

  • Physical ethernet adapter on the host (Wi-Fi is unreliable with external switches)
  • Admin PowerShell on Windows host

Host Setup (one-time)

1. Create the External Switch

New-VMSwitch -Name "ExternalSwitch" -NetAdapterName "Ethernet" -AllowManagementOS $true

The host network will blip for a few seconds while the adapter rebinds. If your adapter name differs, find it with: Get-NetAdapter | Where-Object { $_.Status -eq "Up" }

2. Connect a VM to the switch

Connect-VMNetworkAdapter -VMName "YOUR-VM-NAME" -SwitchName "ExternalSwitch"

This persists across reboots of both host and guest.

Guest Setup (Ubuntu)

1. Verify the interface is up

ip link show

Look for eth0 (or similar) with state UP.

2. Create a NetworkManager connection

sudo nmcli connection add con-name "Wired" type ethernet ifname eth0 ipv4.method auto
sudo nmcli connection up "Wired"

3. Verify

nmcli device status
# eth0 should show: connected / Wired

ip addr show eth0
# Should have an IP from your router's DHCP

ping 8.8.8.8
ping google.com

Why not the Default Switch?

Issue Detail
ICS service breaks silently Windows Updates corrupt SharedAccess; service becomes unkillable
No manual fix without reboot Stop-Service SharedAccess -Force fails when it's wedged
Recurs unpredictably Can break again on next update cycle

The External Switch bridges directly to the physical NIC — no dependency on ICS, WinNAT, or SharedAccess.

Troubleshooting

Symptom Fix
dhclient times out (no DHCP response) Check switch type: Get-VMSwitch | Format-Table Name, SwitchType — must be External
eth0 has no IP after reboot Ensure NetworkManager owns it: nmcli device status should show connected (not connected (externally))
Host loses network after creating switch Verify -AllowManagementOS $true was set; if not: Set-VMSwitch "ExternalSwitch" -AllowManagementOS $true
Multiple VMs need networking Just connect each to the same ExternalSwitch — they'll each get their own DHCP lease from your router
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment