VMware virtual machine Host-Only mode communication and networking

1. Demand

Realize the communication between the host machine and multiple virtual machines, and realize the networking of virtual machines.
Tool: VMware
System: CentOS
Adoption mode: Host-Only
Network topology such as:
insert image description here

2. Network configuration

1. Set the network card mode

Select the network card mode: Only the host mode
virtual machine and the virtual network card of the host machine form a local area network. A separate static internal IP can be used in the local area network. You only need to set the gateway to the address of the virtual network card. In this way, virtual machines can pass through The LAN is interconnected, and the virtual machine is connected to the host through a gateway.
insert image description here

2. View the virtual network

insert image description here
Find the network card name of "host-only mode" as "VMnet1"
insert image description here

3. Set up network sharing

View the network connection of the host machine, and share the network with the virtual network card
insert image description here
Right click on the current network and select "Properties" to share the network with the virtual network card
insert image description here
insert image description here

4. Virtual machine IP configuration

(1) Set a fixed IP:
command:

vi /etc/sysconfig/network-scripts/ifcfg-你的网卡名

Modified and added configuration:

IPADDR=192.168.137.2 实际地址须与GATEWAY在同一网段
NETMASK=255.255.255.0
GATEWAY=192.168.137.1	  即Host-Only Network的IP地址
BOOTPROTO=static / dhcp	  static表示使用静态IP,DHCP使用动态IP
ONBOOT=yes      	  表示开机启动配置

GATEWAY, IPADDR is configured according to the local actual address
insert image description here
(2) Modify DNS

vi /etc/resolv.conf

Add configuration:

nameserver 114.114.114.114
或183.221.253.100、61.139.2.69、8.8.8.8

Then restart the network service:

service network restart
5. View network configuration information
ifconfig

insert image description here
Finally, use the ping command to test whether you can connect to the Internet.
Other virtual machines can be configured in the same way.

6. Pay attention

Due to the bug of win10, every time the computer is restarted, the virtual machine cannot be connected to the Internet. You need to manually cancel the sharing in the network connection panel, and then re-share the network to take effect.
For this problem, a blog can refer to: https://blog.moeyukina.top/index.php/2019/12/08/windowsics/
(but my computer does not take effect...)

Guess you like

Origin blog.csdn.net/weixin_44732379/article/details/124237700