Hyper-V nested virtualisation networking
…aneb jak zasíťovat virtuální stroje na Hyper-V hostiteli, který je sám virtuálkou…
Jsou dvě metody: Mac address spoofing a NAT.
MAC address spoofing:
Je jednodušší a umožňuje zasíťování přes několik virtuálních hostitelů. Adresní prostor se pak překrývá a adresním prostorem hostitele, nebo v hostitelské síti musíte vytvořit router. Řešení pro překrývající se adresní prostor je jednodušši, nicméně…
Celá sranda spočívá ve spoofování MAC adresy virtuálního hostitele, takže to spraví jeden příkaz. Lze pak využít i DHCP server z hostitelské sítě:
Get-VMNetworkAdapter -VMName | Set-VMNetworkAdapter -MacAddressSpoofing On
Metoda překladu adres (NAT):
Router vlastně vytvoříme přímo na virtuálním switchi virtuálního hostitele:
New-VMSwitch -Name "Nested" -SwitchType Internal New-NetIPAddress –IPAddress 192.168.200.1 -PrefixLength 24 -InterfaceAlias "vEthernet (Nested)"
New-NetNat -Name vNATNetwork -InternalIPInterfaceAddressPrefix 192.168.200.0/24
Celý transcript pak vypadá následovně:
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows PS C:\Windows\system32> New-VMSwitch -Name "Nested" -SwitchType Internal Name SwitchType NetAdapterInterfaceDescription ---- ---------- ------------------------------ Nested Internal PS C:\Windows\system32> New-NetIPAddress -IPAddress 192.168.200.1 -PrefixLength 24 -InterfaceAlias "vEthernet (Nested)" IPAddress : 192.168.200.1 InterfaceIndex : 31 InterfaceAlias : vEthernet (Nested) 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.200.1 InterfaceIndex : 31 InterfaceAlias : vEthernet (Nested) AddressFamily : IPv4 Type : Unicast PrefixLength : 24 PrefixOrigin : Manual SuffixOrigin : Manual AddressState : Invalid ValidLifetime : Infinite ([TimeSpan]::MaxValue) PreferredLifetime : Infinite ([TimeSpan]::MaxValue) SkipAsSource : False PolicyStore : PersistentStore PS C:\Windows\system32> New-NetNat -Name vNATNetwork -InternalIPInterfaceAddressPrefix 192.168.200.0/24 Name : vNATNetwork ExternalIPInterfaceAddressPrefix : InternalIPInterfaceAddressPrefix : 192.168.200.0/24 IcmpQueryTimeout : 30 TcpEstablishedConnectionTimeout : 1800 TcpTransientConnectionTimeout : 120 TcpFilteringBehavior : AddressDependentFiltering UdpFilteringBehavior : AddressDependentFiltering UdpIdleSessionTimeout : 120 UdpInboundRefresh : False Store : Local Active : True PS C:\Windows\system32>
Zanechat odpověď