Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IP address change of provisioned VM #22

Closed
Surja1997 opened this issue Jan 4, 2021 · 6 comments
Closed

IP address change of provisioned VM #22

Surja1997 opened this issue Jan 4, 2021 · 6 comments

Comments

@Surja1997
Copy link

Is there a way to change ip_address of the created HyperV VM , such that we can RDP into it. Right now, the only way is to use 'connect' option and then go in there and change TCP/IPv4 using GUI only.

PS- I see a field "ip_addresses" in network adapters, but unable to change it, there is no method as such.

Urgently need it for doing RDP.

In short- how to assign ip address to the generated HyperV Virtual machine using fog-hyperV?

@ananace
Copy link
Owner

ananace commented Jan 10, 2021

Hello,

Hyper-V doesn't actually handle IP addresses, it only supports reading the value that the operating system has assigned to the virtual adapter. There's no way for the hypervisor to set this value, only the OS.
You can read and change the MAC address, as that's the hardware address, but the IP is handled on the operating system level and there's no method for Hyper-V to interfere there.

@ananace ananace closed this as completed Jan 10, 2021
@Surja1997
Copy link
Author

Surja1997 commented Jan 10, 2021 via email

@ananace
Copy link
Owner

ananace commented Jan 10, 2021

To connect to Hyper-V VMs before they have a running OS, you will RDP to the VM host and use the correct parameter for Hyper-V to pass the RDP connection on into the VM console.
https://superuser.com/questions/685968/directly-accessing-hyper-v-console-via-rdp - the answer contains information both for connecting with vmconnect and RDP on Windows, as well as FreeRDP otherwise.

If you - on the other hand - actually need to connect directly to the VM itself, then you will need to let it boot, have it install and run an operating system, let it get an IP address from your DHCP server, and then connect to that IP address.

@Surja1997
Copy link
Author

Surja1997 commented Jan 10, 2021 via email

@ananace
Copy link
Owner

ananace commented Jan 10, 2021

What you will want to do for your use-case would be to set the VM's MAC address in your DHCP server to give it a fixed IP address.
Hyper-V is a regular hypervisor, one that only deals with the virtualization of hardware. The IP address that a running machine acquires isn't able to be decided by the network hardware, it's done on the OS level - either with a client that talks DHCP to get a lease on an address, or by statically configuring an IP address on the interface. Either way, Hyper-V is only able to affect the virtualized hardware itself, and the network adapter hardware itself doesn't have any say in this particular regard.

If other providers - cloud or not - allow for configuring the IP on a virtual machine inside of them, it's most likely done by them running a DHCP server internally which the VM will end up receiving the IP from. Or they're relying on the installation of VM tools, which would let the virtual machine communicate directly with the hypervisor to read a requested IP config and apply it on the OS level.

For my foreman_hyperv plugin, your scenario is done by; the user entering an IP in the Foreman interface when creating a host, a VM is then created in Hyper-V, launched for a second, before then being killed again so that Hyper-V has to generate a MAC address for it, then reconfigured to have that MAC address assigned statically to the adapter. After that, the DHCP server has an entry orchestrated to fix the chosen address to the generated MAC address, which the VM will then pick up when it next boots and runs a DHCP request.

@Surja1997
Copy link
Author

Surja1997 commented Jan 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants