1、虚拟机使用的vmnet8网卡
2、配置网段
newname:~ bytedance$ sudo vim /Library/Preferences/VMware\ Fusion/networking
VERSION=1,0
answer VNET_1_DHCP yes
answer VNET_1_DHCP_CFG_HASH B97A11095F31F026FB4D5291A6E1DA752AC7011D
answer VNET_1_HOSTONLY_NETMASK 255.255.255.0
answer VNET_1_HOSTONLY_SUBNET 192.168.49.0
answer VNET_1_HOSTONLY_UUID 471CBFCC-F7B8-4A20-BF91-C63B2C1332C0
answer VNET_1_VIRTUAL_ADAPTER yes
answer VNET_8_DHCP no
answer VNET_8_DHCP_CFG_HASH 5E44D9C4260BA7903748E5ACC810147355AD9772
answer VNET_8_HOSTONLY_NETMASK 255.255.255.0
answer VNET_8_HOSTONLY_SUBNET 192.168.1.0
answer VNET_8_HOSTONLY_UUID 83198831-2EF1-4083-BF00-82C3229F9F3D
answer VNET_8_NAT yes
answer VNET_8_VIRTUAL_ADAPTER yes
3、配置网关
newname:~ bytedance$ sudo vim /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf
# NAT gateway address
ip = 192.168.1.254
netmask = 255.255.255.0
4、配置DHCP文件
$ sudo vim dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.2 192.168.1.254;
option broadcast-address 192.168.1.255;
option domain-name-servers 192.168.1.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 192.168.1.2;
option routers 192.168.1.2;
}
5、虚拟机网卡配置
IPADDR=192.168.1.1 //自定义的虚拟机IP, 需与VMware Fusion配置的IP在同一个网段上
GATEWAY=192.168.1.254 //网关。1.2中配置的网关地址
NETMASK=255.255.255.0 //掩码。1.2中配置的掩码
DNS1=223.5.5.5
DNS2=223.6.6.6