Explain the installed virtual machine system, how to configure the network and connect to the external network normally.
Virtual machine settings
The virtual machine ignores the description of the centos image installation steps, and selects the "bridge" mode during the installation process.
System ip configuration
After the centos linux system is installed, you need to configure the IP of the network segment that communicates with the physical machine.
- View physical machine configuration
- Configure the virtual machine IP:
ifconfig to check whether the network card is up and active (that is, the first line is in the RUNNING state).
In this article, you need to pay attention to the content in the red box to configure ip by modifying the configuration file.
Main configuration: ip needs to be in the same network segment as the physical machine, the subnet mask and gateway are the same as the physical machine, and set to static ip, boot up and set the network card name
- Restart network service
systemctl restart network
After a normal restart, you can ping the physical machine address and the external network address.
Take Baidu's ip address (112.80.248.76) as an example:
[root@localhost network-scripts]# ping 112.80.248.76
PING 112.80.248.76 (112.80.248.76) 56(84) bytes of data.
64 bytes from 112.80.248.76: icmp_seq=1 ttl=53 time=34.4 ms
64 bytes from 112.80.248.76: icmp_seq=2 ttl=53 time=30.7 ms
(Note: If it doesn't work, please try to turn off the firewall)
service firewalld stop #关闭
firewall-cmd --state #查看防火墙当前状态
4. Other supplements: If you need to ssh to the virtual machine from the physical machine through the CRT software, normally turn on the sshd service at this step, and you can ssh to connect to the virtual machine (default port 22, you can view it under /etc/ssh/ssh_config) .
systemctl start sshd
System DNS configuration
In order to be able to access the Internet, that is, to ping www.baidu.com, you need to configure DNS for domain name resolution. There are two methods:
one: modify through the NetworkManager service
1. Add the DNS domain name as shown in the figure (the same as the physical machine), and turn on the NM_CONTROLLED to select yes, which means that the NetworkManager service can be activated (or not, the default yes).
2.
Restart the NetworkManager service
systemctl restart NetworkManager
At this time, the contents of the /etc/resolv.conf file will be automatically filled in and modified:
[root@localhost network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.1
nameserver 114.114.114.114
At this time, normal ping www.baidu.com is possible.
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14: icmp_seq=1 ttl=54 time=5.90 ms
64 bytes from 39.156.66.14: icmp_seq=2 ttl=54 time=9.08 ms
2: Manually modify the configuration of resolv.conf (personally recommend the first convenience)
1. This method needs to select NM_CONTROLLED as no, which means that the NetworkManager service cannot take effect when it is started.
(Note: If this parameter is no, it is equivalent to adding dns=none in the /etc/NetworkManager/NetworkManager.conf file, both have the same effect)
2. Manually add the contents of the /etc/resolv.conf file.
nameserver 192.168.1.1
nameserver 114.114.114.114