0

Is it possible to assign the MAC reserved IP address as configured in the router DHCP to a Hyper-V guest, while the host will just be assigned a dynamic IP available in the router's DHCP range?

I have a NixOS (Linux) Hyper-V VM running within Windows 10, and don't care what IP I get assigned to the Windows 10 host, but I need the NixOS guest to be assigned a static IP for SSH access. Right now I have configured an external network switch on my WiFi adapter. With this I get an IP from my router for both the host and guest. The problem is however, that it is just the wrong away around, the host is first, so it gets assigned the reserved static IP, and the guest being second gets a dynamic IP from the DHCP range. Is it possible to swap the assignment of these IPs, while still have both host and guest be DHCP clients?

I do not want to assign a static IP because it is a laptop and I only want the static IP when on my home network, while still having functional internet within the VM when on other networks. I get there are plenty of ways to work around this:

  • Check I am on my home network and only then assign a static IP, otherwise default to using a DHCP client.
  • Use some virtual network, e.g. ZeroTier, WireGuard, or OpenVPN.
  • Run something like Avahi on my machines to discover the dynamically assigned IP address.
  • Have a more advanced router where I could implement workarounds in there.
  • Configure the Windows 10 host to forward the SSH port to the NixOS guest.

However I am curious if it is possible with the given constraints, to be assigned a static and dynamic IP from a simple router that only allows a single reserved IP per MAC address, and have the host end up with the dynamic IP and the guest with the static IP.

2
  • The problem is that you’re using bridging with Wi-Fi. Don’t use bridging with Wi-Fi. Instead, use NAT and port forwarding.
    – Daniel B
    Mar 18, 2020 at 11:58
  • use the correct MAC, get it from the VM, not the host and it should correctly assign. You may also want to set your VM to a static MAC address, by default Hyper-V uses dynamic MACs for VMs.
    – essjae
    Mar 18, 2020 at 18:25

1 Answer 1

0

As pointed out in the comments, in the case of WiFi the only way is to use NAT: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/setup-nat-network

The limitation of a single MAC address is a limitation of WiFi adapters. When I used my ethernet adapter instead, it does show the statically assigned MAC address of the VM in the router's DHCP table, so I was able to reserve a static IP address for it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .