I’m running Windows 11 Pro, and have set up a FreeBSD VM under Hyper-V. Initially, the VM was using the default virtual switch, and internet access from the VM worked correctly. But in an attempt to prevent the VM’s IP address from changing on each reboot, I attempted to create a new virtual switch and set up a static IP address with NAT. Currently, the host and guest can ping each other but the guest cannot ping anything through the host’s wifi connection. The VM is set up to use the correct virtual switch in Hyper-V.
I followed this guide on the Microsoft website to set up the NAT, and then I edited /etc/rc.conf on the FreeBSD VM, as follows:
ifconfig_DEFAULT="inet 192.168.0.2 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
Here is the host-side configuration info on the virtual switch, static IP address, and NAT:
PS C:Windowssystem32> get-vmswitch
Name SwitchType NetAdapterInterfaceDescription
---- ---------- ------------------------------
LocalNat Internal
Default Switch Internal
PS C:Windowssystem32> get-netadapter
Name InterfaceDescription ifIndex Status
---- -------------------- ------- ------
vEthernet (LocalNat) Hyper-V Virtual Ethernet Adapter #2 16 Up
Bluetooth Network Conn... Bluetooth Device (Personal Area Netw... 27 Discon...
Wi-Fi Intel(R) Wi-Fi 6E AX210 160MHz 8 Up
vEthernet (Default Swi... Hyper-V Virtual Ethernet Adapter 33 Up
PS C:Windowssystem32> get-netipaddress -InterfaceIndex 16
IPAddress : fe80::ac90:94a:c07b:35fc%16
InterfaceIndex : 16
InterfaceAlias : vEthernet (LocalNat)
AddressFamily : IPv6
Type : Unicast
PrefixLength : 64
PrefixOrigin : WellKnown
SuffixOrigin : Link
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
IPAddress : 192.168.0.1
InterfaceIndex : 16
InterfaceAlias : vEthernet (LocalNat)
AddressFamily : IPv4
Type : Unicast
PrefixLength : 24
PrefixOrigin : Manual
SuffixOrigin : Manual
AddressState : Preferred
ValidLifetime : Infinite ([TimeSpan]::MaxValue)
PreferredLifetime : Infinite ([TimeSpan]::MaxValue)
SkipAsSource : False
PolicyStore : ActiveStore
PS C:Windowssystem32> get-netnat
Name : HyperV-NatNetwork
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
And here’s the output of netstat on the VM:
$ netstat -rn
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.0.1 UGS lo0
127.0.0.1 link#1 UH lo0
192.168.0.0/24 link#2 U hn0
192.168.0.2 link#1 UHS lo0
Internet6:
Destination Gateway Flags Netif Expire
::/96 ::1 UGRS lo0
::1 link#1 UHS lo0
::ffff:0.0.0.0/96 ::1 UGRS lo0
fe80::/10 ::1 UGRS lo0
fe80::%lo0/64 link#1 U lo0
fe80::1%lo0 link#1 UHS lo0
fe80::%hn0/64 link#2 U hn0
fe80::215:5dff:fec8:704%hn0 link#2 UHS lo0
ff02::/16 ::1 UGRS lo0
What have I done wrong?