3

Is possible to setup HyperV virtual machine to have static IP and also have access to internet ? (on latest Windows 10 Pro)

To sum up, requirements are like so:

  • virtual machine should have local (manually defined) IP like 192.168.1.18 (ideally defined from host computer, not in VM)
  • virtual machine should be ideally accessible only from host computer (not from public)
  • virtual machine should have access to internet (from wifi adapter where must be defined DHCP)
  • would be great if Virtual Machine (guest) could stay in DHCP client mode

Machine is created by Vagrant but probably will need manual tweaking - as Vagrant static IP bug is open here.

PS. I am web developer with basic understanding of networking, so please keep that in mind with possible explanations :)

  • 1
    Yes. This is a very common configuration. Have you tried to set this up and are facing some specific problem? – Twisty Impersonator Feb 16 '18 at 15:27
  • Yea I've tried some things but ended neither not able to connect to VM, or not working network at all... :/ so I hoped someone was dealing with similar issue and can provide "dummy style" help. Will try again, and can post details later if no luck... – Jurosh Feb 16 '18 at 16:16
2

Yes, this is possible. You'll use the guest operating system's network configuration utility to set the static IP address. Make sure to include a default gateway and DNS Servers so you can browse the internet.

After that, it's just a matter of setting the firewall to only allow connections from the host machine and blocking all other inbound connections.

  • I was thinking that there is solution without modification of VirtualMachine (guest) - something what will say that virtual machine should be assigned this IP so guest can stay as DHCP client.. Which network interface switch should I use in your example ? – Jurosh Feb 16 '18 at 16:37
  • You'll want an external switch. You can use a MAC address reservation within DHCP if you have access to the DHCP server. You'll have to set a static MAC address and not just he dynamic one generated by HyperV. – Allen Howard Feb 16 '18 at 16:38
  • But there might be one issue, if I type gateway and IP inside machine, will this solution work on all networks ? -- I am connected through WiFi adapter so my network is based on DHCP on place I work.. so host PC can have different IPs (& subnets) as one defined in guest machine... – Jurosh Feb 16 '18 at 16:48
  • If you connect to different networks, then a MAC address reservation won't help. If you statically set a network address in the VM, it won't have access to anything on a different network. Your host NIC would still be using DHCP, and thus would get an IP address properly. – Allen Howard Feb 16 '18 at 16:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.