VMWare - 虚拟操作系统静态IP地址
在 VMWware 中让虚拟操作系统拥有静态 IP 地址的最佳方法是什么? 我想保持 IP 地址静态,因为它是虚拟服务器。
What is the best way to have a virtual operating system have a static IP address in VMWware. I would like to keep the IP address static since it is a virtual server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以配置VMware DHCP服务器[在主机操作系统上运行],以便每次为虚拟机分配固定IP地址。
根据 vmware 文档,配置存储在以下位置:
Windows XP
C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf
Windows Vista 或 Windows 7
C:\ProgramData\VMware\vmnetdhcp.conf
Linux(仅限主机)
/etc/vmware/vmnet1/dhcp/dhcp.conf
Linux (NAT )
/etc/vmware/vmnet8/dhcp/dhcp.conf
VMWare Fusion for Mac(仅限主机)
/Library/Preferences/VMware Fusion/vmnet1/dhcpd.conf
VMWare Fusion for Mac (NAT)
/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf
按 MAC 的静态 IP 和 DNS 名称示例:
有关此内容的更多详细信息,请参阅此 博客文章。
You can configure VMware DHCP server [which runs on host OS] to assign a fix IP address to a VM each time.
According to vmware docs, configuration is stored at the following locations:
Windows XP
C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf
Windows Vista or Windows 7
C:\ProgramData\VMware\vmnetdhcp.conf
Linux (host-only)
/etc/vmware/vmnet1/dhcp/dhcp.conf
Linux (NAT)
/etc/vmware/vmnet8/dhcp/dhcp.conf
VMWare Fusion for Mac (host-only)
/Library/Preferences/VMware Fusion/vmnet1/dhcpd.conf
VMWare Fusion for Mac (NAT)
/Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf
Static IP and DNS name by MAC example:
For more details on this please see this blog post.
假设您没有使用基于 NAT 的 VMWare 网络,那么虚拟(来宾)服务器的答案与真实服务器没有任何不同。 您可以:
Assuming you're not using NAT-based VMWare networking, the answer isn't any different for a virtual (guest) server than for a real one. You can:
如果您希望 VM 切片/VM 计算机(来宾)拥有静态 IP,请将其分配给 VM 切片。 然后在 VM Server 上为网络适配器设置选择“桥接”。 这告诉 VMWare 使用您在来宾上建立的任何 IP 设置。
If you want the VM slice / VM machine (guest) to have a static IP, assign it to the VM slice. Then on the VM Server select "Bridged" for the network adapter settings. This tells VMWare to use what ever IP settings you have established on the guest.
这适用于我的机器
请按照以下简单步骤操作。 只需 5 分钟。
笔记:
以下文件夹会自动同步。在一个位置进行更改,相同的内容将反映在其他文件夹
C:\ProgramData\VMware 上
C:\Documents and Settings\All Users\Application Data\VMware
This works on my machine
Follow these simple steps. Takes just 5 minutes.
Notes:
the below folders are at sync automatically.. change at one place and the same will be reflected on the other folder
C:\ProgramData\VMware
C:\Documents and Settings\All Users\Application Data\VMware
一个简单的解决方法是将 vmware dhcp 服务器 配置为使用更长的租约。
在 vmware config 文件夹(在 windows 7 上 -
C:\ProgramData\vmware
)编辑文件vmnetdhcp.conf 并将
default-lease-time
和max-lease-time
的值更改为更大的比如 4 个月(
4mo*30days*24hours*60min*60sec = 10368000
)。然后重新启动 vmware dhcp 服务器。 然后释放并续订客人的租约。
现在,您的访客 IP 在接下来的四个月内是静态的。
A simple workaround, configure the vmware dhcp server to use longer leases.
In the vmware config folder (on windows 7 --
C:\ProgramData\vmware
) edit the filevmnetdhcp.conf and change the values of
default-lease-time
andmax-lease-time
tosomething bigger say 4 months (
4mo*30days*24hours*60min*60sec = 10368000
).Then restart the vmware dhcp server. Then release and renew the lease on the guest.
Now your guest IP is static for next four months.
如果您希望将 VM 主机配置保留为默认值,也可以将来宾计算机配置为请求 dhcp 的固定地址。 这甚至适用于 NAT 网络。 对于 Ubuntu 和
dhclient
,这是通过dhclient.conf
中的以下块实现的:来源:https://serverfault.com/a/381137
If you prefer to leave the VM host configuration as default, it is also possible to configure the guest machine to request a fixed address for dhcp. This will work even for the NAT network. In the case of Ubuntu and
dhclient
, this is achieved by the following block indhclient.conf
:Source: https://serverfault.com/a/381137