【VMware】Build a personal server

It always feels awkward to run a virtual machine on a Mac notebook. Through VMware virtual machine technology, an idle Windows notebook can be turned into a server for building a cluster.

Preparation

  • Windows used as the host needs to install VMware software

    See website: https://blog.csdn.net/al6nlee/article/details/130792439

  • Turn off the host's firewall to prevent requests from being intercepted

  • The Mac used as the connection machine needs to install the ssh tool, and you can use the built-in terminal (I use Royal TSX)

  • Ensure that the connection machine and the host machine are in the same LAN

Three Network Modes

Open the vmware virtual machine, we can see VMnet0 (bridge mode), VMnet1 (host only mode), VMnet8 (NAT mode) in the "virtual network editor" under "Edit" in the option bar

At the same time, there are two virtual NICs corresponding to VMware Network Adapter VMnet1 and VMware Network Adapter VMnet8 on the host, which work in host-only mode and NAT mode respectively. In "Network Connection", we can see these two virtual network cards. If these two pieces are uninstalled, you can click "Restore Default Settings" in the "Virtual Network Editor" under "Edit" of vmware to re-install them. Virtual NIC restoration.

Bridged (bridge mode)

definition

The bridge mode is to use the virtual bridge to communicate between the host network card and the virtual network card of the virtual machine.

Under the function of bridging, it is similar to virtualizing the physical host as a switch. All the virtual machines set up by bridging are connected to an interface of this switch, and the physical host is also plugged into this switch, so all the network cards and network cards under the bridge are connected. It is in exchange mode and can be accessed without interfering with each other. In bridge mode, the IP address of the virtual machine needs to be on the same network segment as the host. If networking is required, the gateway and DNS need to be consistent with the host network card. Its network structure is shown in the figure below:

set up

  • Edit virtual machine settings

  • "Network Adapter", select "Bridged Mode"

  • First determine the host's ip address, network management, DNS and other information

  • Edit network card configuration file

    vi /etc/sysconfig/network-scripts/ifcfg-eth0

  • Restart the virtual machine network card and test the communication between the virtual machine and the external network

    /etc/init.d/network restart

  • Communication between the virtual machine and the host

NAT (Network Address Translation Mode)

definition

When the network ip resources are in short supply, and you want your virtual machine to be able to connect to the Internet, then the NAT mode is the best choice. The NAT mode uses virtual NAT devices and virtual DHCP servers to enable virtual machines to network. Its network structure is shown in the figure below:

set up

  • Virtual network editor configuration


  • virtual machine configuration

  • Edit network card configuration file

    vi /etc/sysconfig/network-scripts/ifcfg-eth0

  • Restart the virtual machine network card and test with the test virtual machine and the external network

  • Close the VMware Network Adapter VMnet8 virtual network card, test the communication between the virtual machine and the external network & test the communication between the virtual machine and the host

    • Communication between the virtual machine and the external network -> normal communication

    • Communication between the virtual machine and the host -> no communication

Host-Only (host-only mode)

definition

The Host-Only mode is actually the NAT mode that removes the virtual NAT device, and then uses the VMware Network Adapter VMnet1 virtual network card to connect to the VMnet1 virtual switch to communicate with the virtual machine. The Host-Only mode separates the virtual machine from the external network, making the virtual machine a An independent system that only communicates with the host computer.

If we want to enable the virtual machine to be networked, we can share the host network card with the VMware Network Adapter VMnet1 network card, so as to achieve the purpose of virtual machine networking.

Its network structure is shown in the figure below:

set up

  • virtual network editor

  • virtual machine settings

  • Set network card file

  • Restart the network card and test the communication between the virtual machine and the host

  • Set the virtual machine to communicate with the external network

    • Share the network between the host and the VMnet1 network card

    • Reconfigure the virtual network according to 192.168.137.1

    • Reconfigure the network card and use the VMware Network Adapter VMnet1 virtual network card as the route of the virtual machine.

    • Restart the network card, test the communication between the virtual machine and the host machine & external network

build server

Squeeze the remaining value of idle Windows to create a personal server cluster

Network Mode Selection

The bridge mode is essentially a physical machine in the LAN, which has its own IP address, so the local machine in the same LAN can directly access the port of the virtual machine, through the virtual machine IP + virtual machine related tool port number + virtual machine user name and password to connect. Because this is equivalent to directly exposing all ports of the virtual machine.

So I chose the NET mode

  • In NAT mode, the virtual machine can only communicate with the host
  • If the machine (macOS) needs to access this virtual machine, it needs to access it through the forwarding port of the host machine (windows).

Set up port forwarding in VMWare's network editor

The connection port 22 of each virtual machine corresponds to a host port, such as 2201 and 2202 in the figure

View the host's ip address

Command: ipconfig

Connect using ssh connection tool

Guess you like

Origin blog.csdn.net/al6nlee/article/details/130794389