You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Windows 10 Pro最新版中配置Hyper-V虚拟机静态IP并联网

Absolutely, you can pull this off exactly how you want—I’ve set up this exact configuration for test VMs countless times, so let’s walk through it step by step.

Hyper-V VM Setup: Static IP (Host-Defined), Host-Only Access + WiFi Internet

Step 1: Create an Internal Virtual Switch

This switch is the backbone of your setup—it locks the VM to only host access while enabling internet via your WiFi adapter.

  • Open Hyper-V Manager → Click Virtual Switch Manager on the right sidebar
  • Select New virtual network switch → Choose the Internal type → Hit Create Virtual Switch
  • Name it something clear (like Host-Only-WiFi) → Uncheck "Allow management operating system to share this network adapter" (critical to avoid IP conflicts) → Click OK

Step 2: Set a Static IP for the Host’s Internal Adapter

You’ll define a fixed subnet here so your VM can use a matching static IP:

  • Press Win+X → Open Network Connections
  • Find the adapter matching your new internal switch name → Right-click Properties
  • Double-click Internet Protocol Version 4 (TCP/IPv4)
  • Select "Use the following IP address":
    • IP Address: Pick a subnet that doesn’t clash with your WiFi (e.g., 192.168.1.1 if your WiFi uses 192.168.0.x)
    • Subnet Mask: 255.255.255.0
    • Default Gateway: Leave blank
    • DNS Servers: Use your WiFi’s DNS (e.g., 8.8.8.8 or your router’s IP)
  • Click OK to save

Step 3: Assign Static IP to the VM (From the Host)

You have two solid options to define the VM’s IP without touching the VM itself:

Option 1: PowerShell (Clean, Host-Side Control)

Open an elevated PowerShell window and run these commands (replace placeholders with your details):

# Replace with your VM name and desired static IP
$vmName = "YourVMName"
$staticIp = "192.168.1.18"
$subnetMask = "255.255.255.0"
$gateway = "192.168.1.1" # Match your host's internal adapter IP
$dnsServer = "8.8.8.8"

# Lock VM's MAC address to prevent IP drift
Set-VMNetworkAdapter -VMName $vmName -StaticMacAddress "00-15-5D-XX-XX-XX"
# Assign static IP, gateway, and subnet
Add-VMNetworkAdapterAddress -VMName $vmName -IPAddress $staticIp -SubnetMask $subnetMask -DefaultGateway $gateway
# Set DNS for internet access
Set-VMNetworkAdapterDNSConfiguration -VMName $vmName -ServerAddresses $dnsServer

Note: First, make sure your VM is connected to the internal switch you created (edit VM settings → Network Adapter → Select Host-Only-WiFi).

Option 2: ARP Binding (Quick, No VM Changes)

  • Start the VM and let it grab a temporary IP from the internal switch (or manually set 192.168.1.18 once in the VM)
  • Run this elevated PowerShell command to bind the IP to the VM’s MAC address:
# Replace with your VM's MAC and desired static IP
arp -s 192.168.1.18 00-15-5D-XX-XX-XX

This locks the IP to the VM’s hardware address, so it’ll always use 192.168.1.18 without any VM-side config.

Step 4: Enable Internet Sharing via WiFi

Now let the VM piggyback on your host’s WiFi connection:

  • Go back to Network Connections → Find your WiFi adapter (labeled "WLAN" or similar) → Right-click Properties
  • Switch to the Sharing tab
  • Check "Allow other network users to connect through this computer’s Internet connection"
  • From the "Home network connection" dropdown, select your internal switch adapter (Host-Only-WiFi) → Click OK
  • Note: Windows may reset your internal adapter’s IP to 192.168.137.1—just go back and re-set it to 192.168.1.1 (we need the fixed subnet for your VM’s static IP).

Step 5: Verify Everything Works

  • Start the VM, open Command Prompt, and run ipconfig—confirm the IP is 192.168.1.18
  • Test host-VM connectivity: Ping 192.168.1.18 from your host, and 192.168.1.1 from the VM—both should reply
  • Test internet access: Open a browser in the VM and load a website (like google.com)
  • Confirm host-only access: Try pinging the VM from another device on your WiFi network—it should fail (only your host can reach it)

Quick Troubleshooting Tips

  • No internet? Double-check WiFi sharing is enabled, the VM’s gateway matches your host’s internal IP, and DNS is set correctly.
  • Host-VM connection issues? Ensure you unchecked "Allow management operating system to share" on the internal switch, and both devices are on the same subnet.
  • Static IP not sticking? Make sure the VM’s MAC address is set to static (Option 1) or you ran the ARP command as admin.

内容的提问来源于stack exchange,提问作者Jurosh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:44:28