Linux-network connection-(VMware and CentOS), linux-centos
Install CentOS in the vmwarevm to establish a network connection in two steps: intranet connection and internet connection.
Prerequisites:
After you install VMware correctly, the network adapter adds two new NICs: (you can view them in Device Manager> network adapter)
Step 1: intranet connection started when CentOS was installed
Click [custom hardware], network adapter-> Custom [VMnet8 (NAT mode)]. Of course, you can modify it after the installation is complete.
After the installation is complete, run [ip a] to view the current Nic.
Step 2: configure the NIC based on the selected VMnet8. The NIC configuration file naming rule is ifcfg-eno [number ].
[Root @ localhost ~] # Cd/etc/sysconfig/network-scripts/enter the configuration file directory
[Root @ localhost network-scripts] # ls-l you can easily find our Nic configuration file based on the configuration file name
[Root @ localhost network-scripts] # vi ifcfg-eno [number] modify the configuration file
In Control Panel \ network and Internet \ network connection, view the selected IPv4 address of VMnet8. The first three IP addresses of IPADDR must be the same as that of VMnet8, And the last IP address must be 0.
DEVICE = eno [number] // This is the NAME of the NIC = NAME = eno [number] ONBOOT = yes // do you want to start BOOTPROTO = static/static with startup, dhcp indicates random acquisition of ipIPADDR = ***. ***. ***. 150 // manually set the fixed IP address NETMASK = 255.255.255.0 // mask address, which is the mask
Of course, when you open the configuration file, you will see a lot of attributes, except the above attributes, can be deleted.
The NIC configuration file has been modified. Of course, you need to restart the NIC service.
[Root @ localhost network-scripts] # service network restart the network service
Step 3: How can I test whether the intranet connection is successful?
Method: 1. In windows cmd, ping the IPADDR you set. If the message is sent successfully, the message is successful.
2. In CentOS, ping the IPv4 address of VMnet8. If the message is sent successfully, the message is successful.
The above intranet connection is complete!
Step 4: add another ENI. The network connection is in the Bridging Mode: directly connecting to the physical network]
The virtual machine restarts automatically. In this way, the Internet connection is successful.
Test: ping www.baidu.com to access the Internet. Of course, you can also run the command ip address a to view the current Nic. The static ip address we set appears here.