Path 2: Virtual Machine file sharing and network mode.
On New Year's Eve, when other gods quit their old age with their family and welcome the new year, the bloggers did not dare to slack themselves. They thought about a year's plan and made plans early, taking advantage of others' time and writing a log, I feel quite meaningful to spend a peaceful New Year's Eve night... In fact, what's paralyzing is that the blogger has no network or TV at home, and he sees other people's singing and dancing. The noise of a Chinese New Year's Eve makes him helpless, but he can only close the door, using the mobile spring festival traffic special offer package, you can write logs online for the Chinese New Year.
Cough-cough, calm down, cut into the question. In the previous blog on virtual machines, the installation of virtual machines is complete. The system after installation is easy to understand, to talk about the file sharing between the host and the virtual machine and the network mode of the virtual machine. This article is used only to help readers who wish to visit the garden on New Year's Eve ~~
File Sharing
After the virtual machine is installed, you will find that file transmission between the virtual machine and the host machine is a problem. You cannot directly drag files from the host machine to the Virtual Machine desktop, you cannot drag files from the VM to the host. To implement drag-and-drop operations on files, after installing a virtual machine system, we must first install VMware Tools, an enhancement tool that comes with the vmwarevm. It can enhance the performance of virtual graphics cards and hard disks, synchronize drivers of the host and Virtual Machine clock, achieve file sharing between the host and virtual machine, freely drag and drop files, full screen Virtual Machine screen, you can also move the mouse between the host and the virtual machine. The installation is also relatively simple. First, find the installed Toolkit as shown in the figure --
Drag the package to a new directory and run tar-zxvf xx.tar.gz. After the execution, enter the unzipped vmware-toos-distrib directory, run the./vmware-install.pl command with the root user, and press enter to confirm the installation --
After the installation is complete, restart the Virtual Machine. At this time, not only can the Virtual Machine desktop be followed by the host machine in full screen mode, but also the file can be freely dragged to complete the copy function. If you want to uninstall it is also very simple, in the bin directory to execute the executable file wmware-uninstall-tools.pl can easily complete the uninstallation. Of course, it is inconvenient to copy and drag files between the virtual machine and the host machine every time. Fortunately, the virtual machine also provides us with the file sharing function, with VMware Tools installed, you can mount files frequently uploaded to a VM on the host to the path of the VM to implement local access to the host file --
After adding the file, you can view the file directory shared by the host in the/mnt/hgfs directory of the VM --
Network Connection Mode
The installation of virtual machines involves the selection of network connection modes in network adapters. There are three common modes: Bridging Mode, NAT mode, and host-only mode. For many people, during the installation or later configuration process, the bridge mode is usually used as a real machine in the LAN, but as a kind of knowledge and technology accumulation, we should also have a basic understanding of the differences between the three common network connection modes.
Bridging Mode
In the bridge mode, your virtual machine is regarded as a physical machine that exists in the LAN. It communicates with the host machine through a virtual bridge, the host machine acts as a switch. The most basic requirement of this mode is that the host must have a network cable. Otherwise, the virtual machine cannot communicate with the host machine and other physical machines in the LAN; at the same time, this mode requires that the virtual machine and the host machine must be in the same network segment; if the network is to be connected, the gateway and DNS must also be consistent with the host Nic. Set the bridging mode below --
After the mode is set, we need to set the virtual machine and the host machine to the same network segment. Of course, there are more than one way to set this. If the virtual machine is installed with a desktop visualization system, then you can set the Virtual Machine IP address, network segment, subnet mask, and other information through visual operations --
You can view the network information of the host in the network connection --
Of course, our common operation is to modify the NIC configuration of the virtual machine through the command line, execute the command vi/etc/sysconfig/network-scripts/ifcfg-eth0
After entering the edit mode, change the start address protocol BOOTPROTO to static or none, and set the IP address IPADDR. If you want to connect to the Internet, make sure that the gateway and DNS are consistent with the host that can access the Internet. After editing, save and exit, run the service network restart command to enable the NIC configuration to take effect. At this time, you can communicate with the host machine. It is necessary to explain some common information in Nic configuration for configuration reference:
TYPE: interface TYPE of the configuration file. There are multiple network configuration files in the/etc/sysconfig/network-scripts/directory, including Ethernet and IPsec. The network interface TYPE is Ethernet;
DEVICE: the name of the NIC;
BOOTPROTO: indicates the start address protocol, static indicates the static address protocol, none indicates that the address protocol is not enabled, and dhcp indicates the dynamic address protocol;
ONBOOT: Set whether the NIC is activated when the Linux system is started. This parameter must be set to yes;
HWADDR/MACADDR: MAC address. Set one address and avoid conflict;
IPADDR: the IP address of the local machine;
NETMASK: subnet mask;
GATEWAY: the IP address of the GATEWAY;
DNS1: DNS server preferred;
DNS2: Secondary DNS server;
BROADCAST: BROADCAST address;
NETWORK: Subnet address;
IPV6INIT: whether to execute IPv6;
PEERDNS: Specifies whether to use DNS. If DHCP is used, the default value is yes;
NM_CONTROLLED: whether the Network interface is controlled by Network Manager.
NAT Mode
In NAT mode, the host Nic is directly connected to the virtual NAT device. The virtual NAT device and the virtual DHCP server are connected to the virtual switch WMnet8, this virtual network card is used to communicate with the WMnet8 network card on the host machine. If you disable the WMnet8 network card on the host machine (here, the WMnet8 on the Virtual Machine and the WMnet8 we see in the network connection on the host machine are two different NICs, you must note the distinction), you can find that the virtual machine can still be connected to the network, however, you cannot remotely connect to the ECS instance by using the SSH tool. By default, other computers in the same local area network as the physical machine cannot access the virtual machine, but the virtual machine can access other hosts in the LAN. Basic settings --
Run the command to edit the NIC information --
Restart the NIC to take effect. Similarly, you can perform visualized operations --
Only Host Mode
If you want to completely isolate the virtual machine from other hosts in the LAN for security reasons, you only need to perform standalone debugging and choose this mode. Only the host mode is equivalent to the NAT mode to remove the NAT device. Only the WMnet1 virtual Nic of the host machine and the WMnet1 Nic of the virtual machine are used to establish communication, in this mode, the virtual machine and the host machine can access each other. You only need to change the network connection mode to host-only mode in virtual machine settings. If you want to achieve network operations in this mode, you can also share the network adapter of the host to the virtual network adapter WMnet1 --
After the IP address of the WMnet1 virtual network card on the host is set to 192.168.137.1, modify the subnet and start address of the network of the virtual machine to ensure that the network communication is in the same network segment --
Finally, you can edit the NIC configuration file to ensure that the gateway and DNS are consistent with the WMnet1 information.
At this point, on New Year's Eve and evening, firecrackers and wanjia were booming, and the world was so harmonious that the bloggers were also sleepy and did not know why. There may be some leaks, and they will be reserved for future correction. The Year of the Dog, as the Silk program ape, wangwangwang up, beat the times...
Refer to blog: three network modes of vmwarevm