Labbing
Hyper-V
A NAT network can be configured in Hyper-V for use with VMs.
NAT network limit
There is only a single NAT network allowed per host.
A new internal virtual switch is created, with a gateway explicitly configured.
New-VMSwitch -Name Ansible -Type Internal
New-NetIPAddress -IPAddress 192.168.2.1 -PrefixLength 24 -InterfaceIndex 14 # (1)
New-NetNat -Name Ansible -InternalIPInterfaceAddressPrefix 192.168.2.0/24
- Only a single NetIPAddress can be assigned to the interface
WinNAT does not allocate IP addresses to endpoints, so IP addresses must be statically configured within each individual guest.
ip address add 192.168.2.100 dev eth0
ip route add 192.168.2.0/24 dev eth0
ip route add default via 192.168.2.1 dev eth0
WinNAT also does not provide DNS services, so the host's DNS will have to be inspected and used.
WiFi complications
Documentation for VirtualBox states that WLAN adapters do not support promiscuous mode and therefore the Bridge networking option operates differently when using the computer's WiFi adapter. This potentially may be the cause of odd behavior when using External networking in Hyper-V...
Static IP configuration varies by the network management toolset and backend presenton a system. Ubuntu systems use Netplan whereas other distributions most commonly use Network Manager.
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.2.100/24
gateway4: 192.168.2.1
nameservers:
addresses:
- 192.168.1.1
search: []
[connection]
id=Ethernet
uuid=abcdef01-2345-6789-0abc-def012345678
type=ethernet
interface-name=eth0
[ethernet]
[ipv4]
address1=192.168.2.100/24,192.168.2.1
dns=10.40.7.2
method=manual
[ipv6]
addr-gen-mode=stable-privacy
method=auto
WSLv2 distros will not be able to access Hyper-V guests unless forwarding is enabled on both IP interfaces for the Hyper-V NAT as well as WSL
Set-NetIpInterface -ifIndex $NAT -Forwarding Enabled
Set-NetIpInterface -ifIndex $WSL -Forwarding Enabled # (1)
- The setting for the WSL interface appears not to be persistent.
History
Traditionally, network interfaces on Linux were configured in /etc/network/interfaces