vmware fusion NAT no internet connection

确切地说是在 NAT 模式下不使用 dhcp 而是设置 static ip 时无法连接到 internet 网络。

尽管已经尝试了设置 dns nameservers 到多种 ips 都无法解决。

最终只能采取 dhcp 保留地址的方法,能够在得到固定地址的同时也保持互联网连接能力。

https://communities.vmware.com/t5/VMware-Fusion-Discussions/How-to-set-a-DHCP-reservation-on-VMware-Fusion-8-5-on-a-MacBook/m-p/484918

When you open dhcp.conf , you could see some lines like:

1
2
3
4
5
6
7
host vmnet8 {
    hardware ethernet 00:50:56:C0:00:08;
    fixed-address 192.168.87.1;
    option domain-name-servers 0.0.0.0;
    option domain-name "";
    option routers 0.0.0.0;
}

You can just follow the reservation for vmnet8, say:

1
2
3
4
host win7 {
    hardware ethernet 00:50:56:32:FF:3F;
    fixed-address 192.168.87.16;
}

While “hardware ethernet “ stands for the MAC address of your VM, you can get that information by Virtual Machine-> Settings->Network Adapter->Advanced Options; “fixed-address” stands for the IP you want to assign/bind to that MAC address.

You’d better shutdown your VM,then edit /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf and use

$sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli –stop

$sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli –start to restart your network services for Fusion.

When that’s done, power on your VM and see if it gets the IP you want. Of course, you VM should NAT network.Smiley Happy

Hope that will help.

1
2
3
4
5
6
7
# sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop
# sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
host u20s {
	hardware ethernet 00:0C:29:B3:F5:76;
	fixed-address 172.16.207.60;
}


补充

img

在 macOS 中,VMWare Fusion 的配置文件在 /Library/Preferences/VMware Fusion 之中。

需要修改的是 /Library/Preferences/VMware Fusion/vmnet8/dhcpd.conf 这个文件,用纯文本编辑器例如 Sublime Text 或者 TextMate 等打开它,避免用 TextEdit 之类的文本工具(它们会修改半角字符为全角或者unicode字符,转换纯文本为 rich 格式)。一个完整的 dhcpd.conf 示例文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# See Instructions below if you want to modify it.
#
# We set domain-name-servers to make some DHCP clients happy
# (dhclient as configured in SuSE, TurboLinux, etc.).
# We also supply a domain name to make pump (Red Hat 6.x) happy.
#


###### VMNET DHCP Configuration. Start of "DO NOT MODIFY SECTION" #####
# Modification Instructions: This section of the configuration file contains
# information generated by the configuration program. Do not modify this
# section.
# You are free to modify everything else. Also, this section must start 
# on a new line 
# This file will get backed up with a different name in the same directory 
# if this section is edited and you try to configure DHCP again.

# Written at: 07/10/2020 15:59:19
allow unknown-clients;
default-lease-time 1800;                # default is 30 minutes
max-lease-time 7200;                    # default is 2 hours

subnet 172.16.207.0 netmask 255.255.255.0 {
	range 172.16.207.128 172.16.207.254;
	option broadcast-address 172.16.207.255;
	option domain-name-servers 172.16.207.2;
	option domain-name localdomain;
	default-lease-time 1800;                # default is 30 minutes
	max-lease-time 7200;                    # default is 2 hours
	option netbios-name-servers 172.16.207.2;
	option routers 172.16.207.2;
}
host vmnet8 {
	hardware ethernet 00:50:56:C0:00:08;
	fixed-address 172.16.207.1;
	option domain-name-servers 0.0.0.0;
	option domain-name "";
	option routers 0.0.0.0;
}
####### VMNET DHCP Configuration. End of "DO NOT MODIFY SECTION" #######

# sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop
# sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start

host u20s {
	hardware ethernet 00:0C:29:B3:F5:76;
	fixed-address 172.16.207.60;
}

host mageia-8 {
	hardware ethernet 00:50:56:24:B5:8A;
	fixed-address 172.16.207.51;
}

host kali-linux {
	hardware ethernet 00:0c:29:b9:05:bd;
	fixed-address 172.16.207.66;
}

:end: