ILD

Hyper-v配置NAT
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2021-3-2 站点:Inside Linux Development

首先开启PowerShell。win10默认不允许powershell运行,删除注册表

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun

中所有的powershell条目。


Hyper-v添加一个内部交换机。配置IP:192.168.137.1,子网掩码:255.255.255.0


PowerShell执行:

1
New-NetNat -Name mynat -InternalIPInterfaceAddressPrefix 192.168.137.0/24


在虚拟机里面配置:网关为192.168.137.1即可。注意要重启电脑,不然虚拟机ping 192.168.137.1不通,在windows里面也ping不通192.168.137.1,很奇怪。


https://docs.microsoft.com/en-us/powershell/module/netnat/new-netnat

Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.