由於在macOS下實在仍受不了VirtualBox的各類Bug和低性能,轉投熟悉的VMware Fusion後原本一直都挺穩定的,但在一次Linked Clone連接克隆中發現NAT網絡下VM能夠訪問外網但宿主機和虛擬機之間的網絡卻沒法ping通,查閱了很是多的資料仍然無解差點就要暴力選擇添加一塊新網卡作host-only,最後發現重啓下VMware Fusion網絡就恢復了,這大概就是傳說中的無腦重啓解決一切問題。ios
2020年06月16日 - 初稿git
閱讀原文 - https://wsgzao.github.io/post...github
網上解決方案:bash
以上方法統統無效
# 重啓vmware network服務解決問題 sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --stop sudo /Applications/VMware\ Fusion.app/Contents/Library/vmnet-cli --start
VMware Fusion 安裝完成後,會在macOS中新建兩個網卡:vmnet1以及vmnet8(在 /Library/Preferences/VMware Fusion
下能夠看到)網絡
這裏僅對網卡vmnet8 進行修改(修改過程當中需關閉VMWare Fusion)app
sudo vi /Library/Preferences/VMware\ Fusion/networking VERSION=1,0 answer VNET_1_DHCP yes answer VNET_1_DHCP_CFG_HASH E805FD2F642680617F0D09147C8D5C5ED962ED29 answer VNET_1_HOSTONLY_NETMASK 255.255.255.0 answer VNET_1_HOSTONLY_SUBNET 172.16.131.0 answer VNET_1_VIRTUAL_ADAPTER yes answer VNET_8_DHCP yes answer VNET_8_DHCP_CFG_HASH ABBB4D6B9DEC5639F2756A1991B197986AB5597E answer VNET_8_HOSTONLY_NETMASK 255.255.255.0 answer VNET_8_HOSTONLY_SUBNET 192.168.184.0 answer VNET_8_NAT yes answer VNET_8_VIRTUAL_ADAPTER yes add_bridge_mapping en0 2
注意:只修改 vmnet8 的配置, 不要修改vmnet1的配置。tcp
sudo vi /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf # VMware NAT configuration file # Manual editing of this file is not recommended. Using UI is preferred. [host] # NAT gateway address ip = 192.168.184.2 netmask = 255.255.255.0 # VMnet device if not specified on command line device = vmnet8 # Allow PORT/EPRT FTP commands (they need incoming TCP stream ...) activeFTP = 1 # Allows the source to have any OUI. Turn this on if you change the OUI # in the MAC address of your virtual machines. allowAnyOUI = 1 # Controls if (TCP) connections should be reset when the adapter they are # bound to goes down resetConnectionOnLinkDown = 1 # Controls if (TCP) connection should be reset when guest packet's destination # is NAT's IP address resetConnectionOnDestLocalHost = 1 # Controls if enable nat ipv6 natIp6Enable = 0 # Controls if enable nat ipv6 natIp6Prefix = fd15:4ba5:5a2b:1008::/64 [tcp] # Value of timeout in TCP TIME_WAIT state, in seconds timeWaitTimeout = 30 [udp] # Timeout in seconds. Dynamically-created UDP mappings will purged if # idle for this duration of time 0 = no timeout, default = 60; real # value might be up to 100% longer timeout = 60 [netbios] # Timeout for NBNS queries. nbnsTimeout = 2 # Number of retries for each NBNS query. nbnsRetries = 3 # Timeout for NBDS queries. nbdsTimeout = 3 [incomingtcp] # Use these with care - anyone can enter into your VM through these... # The format and example are as follows: #<external port number> = <VM's IP address>:<VM's port number> #8080 = 172.16.3.128:80 [incomingudp] # UDP port forwarding example #6000 = 172.16.3.0:6001
設置網關爲192.168.111.2,網關的IP要和上一步中的IP保持網關一致,至此VMware Fusion的配置完畢。post
vi /etc/sysconfig/network-scripts/ifcfg-ens33性能
TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no NAME=ens33 DEVICE=ens33 ONBOOT=yes IPADDR=192.168.111.100 // 自定義的虛擬機IP, 需與VMware Fusion配置的IP在同一個網段上 GATEWAY=192.168.111.2 // 配置的網關地址 NETMASK=255.255.255.0 // 配置的掩碼 DNS1=114.114.114.114 // macOS本機的DNS地址。 系統偏好設置-> 網絡 -> 在左側選擇當前使用的網絡,點擊右下角的「高級」按鈕 -> 切換Tab頁,可找到DNS地址。 DNS2=8.8.8.8 // 同上 # 保存退出,重啓網絡服務 systemctl restart network
Troubleshooting networking and internet connection issues in VMware Fusion (1016466)this