1.hostnamectl Query Computer version
2.yum Install Package-y # #安装软件,-y indicates that the installation process prompts all Yes
3. Real machine becomes router
Systemctl Stop Libvirtd.service Virtual machine Service "Virtual machine service conflicts with Firewall service"
Systemctl Restart Firewalld reboot firewall
Systemctl Restart Libvirtd.service Open LIBVIRTD
Firewall-cmd--add-masquerade # allows firewalls to spoof IP
Firewall-cmd–-list-all displaying firewall information
Firewall pseudo IP is allowed when Masquerade:yes is displayed as yes under the Firewall-cmd–-list-all command
4. Modify the network file to make the virtual machine go online
!! Network Restart required after configuration file changes
"1" graphical mode IP set
Nm-connection-editor
Add添加
Select Ethernet
Modify Name
Add under IPv4
(Address under Add virtual machine ip,netmask add subnet mask below)
【2】在虚拟机/etc/sysconfig/network文件中写入下面的内容(为了配置全局的网关) vim /etc/sysconfig/network
Nerworking=yes activating networking at startup
Nozeroconf=yes It is a dynamic configuration protocol that the system can use to connect to the network.
gateway=172.25.254.160 IP Address "set global gateway" for your own true machine address
"3" systemctl Restart network restart Web service
"4" At this time can be through the IP internet (at this time only through the IP Internet, no DNS server, nor do they have to establish the corresponding IP and URL), you can use ping domain name (URL)
This method can check the IP
such as Ping www.baidu.com
will be able to find Baidu's IP
Baidu's IP is 220.181.111.188
解决方法: 1】在/etc/hosts文件下可以书写ip与域名的对应关系,就可以通过域名访问对因的ip
2 "Configure DNS
"5"
"Route-n View Gateway"
If the Internet is not available, first check the virtual machine gateway, if there is no problem, you need to check the configuration of the real machine
5. Make the virtual machine go online by modifying the files in the Network-scripts directory
"1" in the following directory settings cd/etc/sysconfig/network-scripts
"2" ls, then rm-fr ifcfg-ens3 remove the NIC configuration file from this directory
"3" Touch ifcfg-ens3 re-establish this file
"4" vim Ifcfg-ens3 writes to this file
Write the following content
DEVICE=ENS3 Network card name (view via Ifconfig)
Onboot=yes whether the network adapter is activated when the net starts
BOOTPROTO=NONE/DHCP Specify IP acquisition method, manual fetch/Auto
ipaddr0=172.25.254.129 Specify IP
netnask0=255.255.255.0 Subnet mask (you need to specify only one)
PREFIX0=24 Subnet Mask
gateway0=172.25.254.29 Gateway
dns1=114.114.114.114 DNS1
Dns2= DNS2 (up to two specified)
Configuration End
"5" Systemctl Restart network Refresh (!!!!!! )
"6" Route-n View Gateway
cat/etc/resolv.conf View DNS
If OK, the virtual machine configuration is complete, if there is a problem, see the real machine, you can first view the state of the firewall;
Linux (real computer as a router to make a virtual machine go online)