Linux (real computer as a router to make a virtual machine go online)

Source: Internet
Author: User
Tags dns2

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.