Clone
4
3.6 Hyper V
jsc-wiki edited this page 2026-10-14 06:27:29 +00:00

Hyper-V

第3章 虛擬化 · 來源:JSC 知識庫

簡介

在 Hyper-V 啟用巢狀虛擬化、MAC 位址偽裝,並建立具 NAT 功能的虛擬交換器,供虛擬機(例如 PVE)使用。

步驟

1. 啟用 KVM

Set-VMProcessor -VMName "<vm_name>" -ExposeVirtualizationExtensions $true

2. 偽裝 MAC 地址 for PVE

因為虛擬機共用同一張網路卡,為了防止流量進到 PVE 後,不再往虛擬機送,因此需要偽裝 MAC 地址

Get-VMNetworkAdapter -VMName "<vm_name>" | Set-VMNetworkAdapter -MacAddressSpoofing On

3. 限制虛擬硬碟的讀寫速度(IOPS)

一個 IOPS 為 8KB / s,如果要限制虛擬硬碟只能使用 100MB / s 的速度,則 IOPS 應該設定為 12800 (100 * 1024 / 8)

4. 加入具 NAT 功能的虛擬交換器

加入新的虛擬交換器

New-VMSwitch -SwitchName "NAT Switch" -SwitchType Internal

設定交換器的 IP

New-NetIPAddress -IPAddress 192.168.30.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NAT Switch)"

設定 NAT

New-NetNat -Name "NAT Network" -InternalIPInterfaceAddressPrefix 192.168.30.0/24

← 3.5 解決Windows安裝WSL後死機的問題 · 本章目錄 · 全書目錄 · 3.7 WSL:從零開始 →