HyperV創建NAT網絡
阿新 • • 發佈:2018-03-27
cti prefix lin intel 名稱 session pan time gui
創建NAT內部網絡,使用PowerShell完成。 https://docs.microsoft.com/zh-cn/virtualization/hyper-v-on-windows/user-guide/setup-nat-network 1.創建Internal網卡,名稱為SwitchNAT PS> New-VMSwitch -SwitchName "SwitchNAT" -SwitchType Internal Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ SwitchNAT Internal 2.獲得SwitchNAT的ifIndex,此例子是45 PS> Get-NetAdapter Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- vEthernet (SwitchNAT) Hyper-V Virtual Ethernet Adapter 45 Up 00-15-5D-CF-BD-05 10 Gbps Bluetooth Network Conn... Bluetooth Device (Personal Area Netw... 4 Disconnected xx-xx-xx-xx-xx-xx 3 Mbps Ethernet Intel(R) Ethernet Connection I219-LM 14 Disconnected xx-xx-xx-xx-xx-xx 0 bps Wi-Fi Intel(R) Dual Band Wireless-AC 8260 12 Up xx-xx-xx-xx-xx-xx 115.6 Mbps 3.創建NAT網關 PS> New-NetIPAddress -IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceIndex 45 IPAddress : 192.168.0.1 InterfaceIndex : 45 InterfaceAlias : vEthernet (SwitchNAT) AddressFamily : IPv4 Type : Unicast PrefixLength : 24 PrefixOrigin : Manual SuffixOrigin : Manual AddressState : Tentative ValidLifetime : Infinite ([TimeSpan]::MaxValue) PreferredLifetime : Infinite ([TimeSpan]::MaxValue) SkipAsSource : False PolicyStore : ActiveStore IPAddress : 192.168.0.1 InterfaceIndex : 45 InterfaceAlias : vEthernet (SwitchNAT) AddressFamily : IPv4 Type : Unicast PrefixLength : 24 PrefixOrigin : Manual SuffixOrigin : Manual AddressState : Invalid ValidLifetime : Infinite ([TimeSpan]::MaxValue) PreferredLifetime : Infinite ([TimeSpan]::MaxValue) SkipAsSource : False PolicyStore : PersistentStore 4.創建一個NAT網絡配置,名稱為MyNAT4HyperV PS> New-NetNat -Name MyNAT4HyperV -InternalIPInterfaceAddressPrefix 192.168.0.0/24 Name : MyNAT4HyperV ExternalIPInterfaceAddressPrefix : InternalIPInterfaceAddressPrefix : 192.168.0.0/24 IcmpQueryTimeout : 30 TcpEstablishedConnectionTimeout : 1800 TcpTransientConnectionTimeout : 120 TcpFilteringBehavior : AddressDependentFiltering UdpFilteringBehavior : AddressDependentFiltering UdpIdleSessionTimeout : 120 UdpInboundRefresh : False Store : Local Active : True 5.在HyperV的虛擬機網卡配置中選擇SwitchNAT 6.啟動虛擬機,手動配置 IP為192.168.0.x, 子網掩碼255.255.255.0, 網關192.168.0.1, DNS為8.8.8.8,8.8.4.4 ----- 刪除命令 先停止使用網卡(關閉虛擬機或服務) PS> Get-NetNat "MyNAT4HyperV"| Remove-NetNat PS> Remove-NetIPAddress -InterfaceAlias "vEthernet (SwitchNAT)" -IPAddress 192.168.0.1 PS> Remove-VMSwitch -SwitchName "SwitchNAT"
HyperV創建NAT網絡