[Linux virtual machine installation and network configuration]

Linux virtual machine installation and network configuration
When Xiaobai just started learning to build a platform, he suffered a loss on the distribution network. After the successful distribution network, he happily recorded it - with a virtual machine installation tutorial (more detailed version) here Let me tell you, I built a virtual machine for learning and use, so the configuration of the virtual machine is very low, and the network connection is set to NAT. Synchronizing with me is more suitable for students to study, but not suitable for working parties.

  1. Mirror version: CentOS7
  2. Version of VMWare:

img
1. Create a virtual machine 1. Click Create imgNext step :img

Pay attention to compatibility here:img

Select a disc image file: (here you can also choose not to choose the image later)img

Name it, and then change the location of the virtual machine: imgMy computer configuration is not high (just for learning), and it can be adjusted a little more if conditions permit:img

This is the same, it doesn’t need too much memory (because I built the virtual machine for learning, if it is for work, I should give more memory) Here I choose NAT: Here I want to talk imgabout NAT and bridging, I checked the relevant information on the Internet before, I personally think that if you build a virtual machine for your own learning, then NAT is actually very OK. It is very convenient for the virtual machines in your computer to ping each other, so I use the NAT mode. As for bridging, I think it is more suitable for working parties. Multiple computers can access a virtual machine.img

Next step (default): imgIn the next step: or default imgNext create a new virtual disk:img

20G memory is basically enough for learning: I usually save the virtual disk as a single file. In order to improve access efficiency, multiple files are better.img

Continue to the next step:img

Custom hardware: imgI removed the sound card and printer, because I don't need it, check the image file again by the way:img

Here comes the key! ! Look here: The network adapter should select VMnet8 in NAT mode, imgthen click Close to start creating a virtual machineimg

Here I want to explain. If you don’t want a graphical interface, just choose the minimal installation. If you want a graphical interface, click on the software selection. See my next picture and choose GUI. Here I recommend the novice Xiaobai to choose the graphical interface. If you know some Linux commands, I still recommend the minimal installation, because the minimal installation really runs very fast! Very fast! The graphical interface is stuck (maybe my computer is not very good?) imgimgThen there are configuration partitions: imgimgthere are three to configure, one is /, the other is /boot and the other is swap (maybe my configuration is not standard, I hope there will be more Please correct me) img imgand then click Finish imgand then create a user and set a password img. I forgot to circle here. It is recommended to set the user as an administrator user, which is more convenient. PS: If the password is too simple, click twice to complete. imgThen wait slowly... imgrestart after the end

2. During this period of network distribution, we may take this opportunity to do another thing, the preparation of network distribution: First check the host IP and DNS: 1. win+R, then enter cmd and press Enter to check the IPv4 address of your own img img
VMnet8 And subnet mask: imgcheck your DNS again: imgwrite down these three sets of numbers

2. Set the network adapter Control Panel - Network and Internet - Network and Sharing Center - Change Adapter Settings - WLAN (Run Properties as Administrator) - Sharing - Check All - Home Network Connection Select VMnet8 3. VMware Settings: (to
img
close virtual machine) Edit - Virtual Network Editor: 1) Click Change Configuration (click to run as an administrator)img

Note: 1. Before configuring the subnet IP, check the IPv4 address and subnet mask of VMnet8 in the command prompt with ipconfig -all. The filled subnet ip and the IPv4 address of VMnet8 should preferably be different, but they must be on the same network segment . 2. If there is an error in the VMnet8 settings, the subnet IP and subnet mask are inconsistent. Eg1: The IPv4 address of VMnet8 is 192.168.137.1, and the subnet mask is 255.255.255.0. Then the subnet ip can be set to: 192.168.137.0, and the subnet mask is 255.255.255.0. This virtual network editor is for adding network cards. Adding VMnet8 is to add a virtual network card to your real computer. This address is the network segment where the network card is located, not the IP address. 3) Click the NAT setting in the above picture, set the gateway to set the gateway: Change the last digit of the IPv4 address of VMnet8 to 2. Eg: 192.168.137.2 4) Click the DNS setting in the lower right corner and then turn off automatic detection in the DNS setting, and set the first one to be the same DNS as the host.
img
4. Open the virtual machine for network configuration (1) su root //Enter administrator status (2) ifconfig //View network devices (eg: ens33) non-image: ip addr (3) vim /etc/sysconfig/network- scripts/ifcfg-ens33 Minimize the interface: vi /etc/sysconfig/network-scripts/ifcfg-ens33 (ens33 is my computer, not everyone is ens33) Modify the network parameters: Two changes: 1. BOOTPROTO=static 2. ONBOOT=yes Four additions: IPADDR=192.168.137.128 (it doesn’t have to be 128, let me give you an example) NETMASK=255.255.255.0 GATEWAY=192.168.137.2 //The above settings check the fourth step VMware setting DNS1=host’s DNS and then exit saveimg

(4) service network restart //restart the network
(5) ping www.baidu.com //ping the external network
(6) ping IP (your own virtual machine ip) //ping the host
img
and then it's over hahahahahahaha

Problem: If you use a wireless wlan to connect to the computer network, the DNS will always change, and the virtual machine will not be able to connect to the external network, that is, the DNS resolution will fail. Change the DNS to static. Steps If the computer is connected to a WLAN, the
network
DNS It will change frequently. At this time, it is better to change it to dynamic acquisition. The DNS setting of the virtual machine needs to be changed according to the network change. If you change the network, you need to
change
the DNS. The IP of VMnet8 is the network segment of the virtual machine, which may not be in the same network segment as this machine. ,
steps:
1. Close the virtual machine, edit the virtual machine network settings, NAT, DNS to local DNS
2. Open the virtual machine, modify DNS1, see the above operation
3. Restart the network

Guess you like

Origin blog.csdn.net/weixin_46356409/article/details/126808607