VMWare - 虚拟操作系统静态IP地址

发布于 2024-07-11 11:44:08 字数 69 浏览 9 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

云巢 2024-07-18 11:44:08

您可以配置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 名称示例:

host ubuntu {
    hardware ethernet 00:0c:29:c0:2c:58;
    fixed-address 192.168.118.3;
} 

有关此内容的更多详细信息,请参阅此 博客文章

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:

host ubuntu {
    hardware ethernet 00:0c:29:c0:2c:58;
    fixed-address 192.168.118.3;
} 

For more details on this please see this blog post.

傲娇萝莉攻 2024-07-18 11:44:08

假设您没有使用基于 NAT 的 VMWare 网络,那么虚拟(来宾)服务器的答案与真实服务器没有任何不同。 您可以:

  • 通过来宾操作系统支持的任何机制分配静态 IP。
  • 配置来宾操作系统从 DHCP 服务器获取其 IP 地址,并将 DHCP 服务器配置为返回 VMWare 实例 MAC 地址的静态 IP 地址。

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:

  • Assign a static IP via whatever mechanism the guest operating system supports.
  • Configure the guest operating system to get its IP address from a DHCP server, and configure the DHCP server to return a static IP address for the VMWare instance's MAC address.
寻找我们的幸福 2024-07-18 11:44:08

如果您希望 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.

万劫不复 2024-07-18 11:44:08

这适用于我的机器

请按照以下简单步骤操作。 只需 5 分钟。

1. Note the MAC of the VM
2. On the host machine open C:\ProgramData\VMware\vmnetdhcp.conf
    a. Or C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf 
    b. These 2 files are auto synced or mirrored. 
    c. Open the editor in Administrator mode. Eg notepad++. Otherwise you will get access denied message
3. Add a new entry at bottom of the configuration file, right before the "# End" marker. MyGuestVM is any unique name. Example below

host sunilW2008Server {
hardware ethernet 00-0C-29-05-2B-A0;
fixed-address 192.168.63.222;
}

3. Shutdown the VM and close the Workstation
4. Re-start the VMWare DHCP and NAT services for changes to take effect (From services.msc)

笔记:
以下文件夹会自动同步。在一个位置进行更改,相同的内容将反映在其他文件夹

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.

1. Note the MAC of the VM
2. On the host machine open C:\ProgramData\VMware\vmnetdhcp.conf
    a. Or C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf 
    b. These 2 files are auto synced or mirrored. 
    c. Open the editor in Administrator mode. Eg notepad++. Otherwise you will get access denied message
3. Add a new entry at bottom of the configuration file, right before the "# End" marker. MyGuestVM is any unique name. Example below

host sunilW2008Server {
hardware ethernet 00-0C-29-05-2B-A0;
fixed-address 192.168.63.222;
}

3. Shutdown the VM and close the Workstation
4. Re-start the VMWare DHCP and NAT services for changes to take effect (From services.msc)

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

为你鎻心 2024-07-18 11:44:08

一个简单的解决方法是将 vmware dhcp 服务器 配置为使用更长的租约。
vmware config 文件夹(在 windows 7 上 - C:\ProgramData\vmware)编辑文件
vmnetdhcp.conf 并将 default-lease-timemax-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 file
vmnetdhcp.conf and change the values of default-lease-time and max-lease-time to
something 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.

口干舌燥 2024-07-18 11:44:08

如果您希望将 VM 主机配置保留为默认值,也可以将来宾计算机配置为请求 dhcp 的固定地址。 这甚至适用于 NAT 网络。 对于 Ubuntu 和 dhclient,这是通过 dhclient.conf 中的以下块实现的:

interface "eth0" {
    send dhcp-requested-address 192.168.1.222;
}

来源: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 in dhclient.conf:

interface "eth0" {
    send dhcp-requested-address 192.168.1.222;
}

Source: https://serverfault.com/a/381137

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文