-1

I am running Hyper-V on Windows 10 and created an Ubuntu server vm running postgresql. My pc has a single nic card. There is a single network adapter on the VM that is connected to the Default switch in Hyper-V. I am able to connect to the internet from the vm and can connect to the instance of Postgresql on the VM from the host and everything works fine. But each time I reboot the VM it gets a new IP address so everyday I have to reconfigure the connection string on my app that makes calls to the Postgresql instance on the vm. How can I configure the ip addresses that are assigned to the devices on the vlan (not sure if that is the correct term) that are sitting behind the Default Switch? I am guessing there is a DHCP server somewhere but I can't find anything.

I just want to have the same ip always assigned to the VM or be able to set the ip manually and know that it is not going to be assigned to another VM, but am at a loss as to how to do what seems like should be a super simple thing.

  • 1
    Voting to close. "Questions should demonstrate reasonable information technology management practices." is not compatible with not knowing your own network ("I am guessing there isa DHCP server somewhere"). This question is better served on superuser.com. – TomTom May 28 at 4:42
3
  1. Assign static IP inside a Hyper-V VM.
  2. Bind VM's MAC address to IP on your router that runs DHCP. Probably it is a wireless physical router connected to your Windows 10 host.
| improve this answer | |
1

You assign an IP address to a virtual machine the same as you do for a physical machine. Either via DHCP or manual configuration. If you don't want to use DHCP then manually configure the IP address settings in the virtual machine.

| improve this answer | |
0

I think it will be better to create custom internal (NAT) switch, which i think doesnt have DHCP capabilities by default.

https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/setup-nat-network

| improve this answer | |
  • Or just SET the static IP - all of which is as trivial as it gets. – TomTom May 28 at 7:17

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