虚拟机如何计算出主机节点的地址?
Linux虚拟机如何计算出主机节点的IP地址?
我需要连接到主机节点的IP地址。我还需要知道它何时发生变化,因为它可能是动态 IP。我需要它来连接到那里的服务。 无论 VM、VMWare、Xen、Virtual Box 的类型如何,是否有某种方法可以检查这一点?
它需要是一个 Linux 脚本,并且无论主机操作系统如何,无论是 Linux 还是 Windows,都应该可以工作
How can a Linux VM work out the IPaddress of the host node?
I need to connect to the IP address of the host node. I also need to know when it changes as it could be a dynamic IP. I need it to connect to a service there.
Is there some way to check this, irregardless of the type of VM, VMWare, Xen, Virtual Box?
It needs to be a Linux script, and should work regardless of the host operating system, whether Linux or Windows
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案是将虚拟机中的网络适配器与主机上的网络适配器桥接,使其成为动态 IP 地址。因此,它将始终作为主机适配器位于子网上。
接下来是在主机 IP 上运行 HTTP 服务,VM 将扫描其网络范围。服务响应的 IP 将是主机的 IP。在主机上拥有 IP 服务并不理想,但这是我能想到的最好的。
My solution is to bridge a network adapter in the VM with one on the host, making it a dymanic IP address. As such it will always be on the subnet as the host adapter.
Next thing is to run an HTTP service on the host IP, that the VM will scan its network range on. The IP the service responds on will be the IP of the host. Having an IP service on the host is not ideal, but it is the best I can come up with.