Linux beginner-Virtual machine Networking Chapter

Source: Internet
Author: User

Linux Beginner-Virtual machine Networking Chapter

In the use of virtual machines, the computer can connect to the WiFi direct Internet, but sometimes need to use the virtual machine network, then in the case of local network, virtual machine How to network it? Next, you'll learn how to make a virtual machine go online when the computer is already connected to WiFi.

The principle of virtual machine access is to make their own native router, and then make the virtual machine connected to the "router" to connect the external network.

The following configuration is required on this machine:

1, if the machine itself has a gateway, delete its own gateway, because as a router is also temporary use, so it is recommended to use "#" comment out. Because the gateway is automatically configured after you connect to Wi-Fi, it prevents any impact.

2. After connecting to WiFi, enter "Ifconfig" To view the native IP and network IP. For example, you can see that the native IP is "172.25.254.2" and the network IP is "192.168.43.28".

3. Enter "Route-n" to view the automatically acquired gateway, for example, the gateway is "192.168.43.1".

4, the firewall policy

4.1 If the firewall is not turned on, first turn on the firewall, and then enter "Firewall-cmd--list-all" to see if there is a firewall policy, as shown, no firewall policy is displayed.

4.2 Enter "Firewall-cmd--permanent--add-masquerade" To turn on "Masquerade" and enter Firewall-cmd--permanent--add-rich-rule= ' rule family= "IPv4" source address=192.168.43.28 Masquerade ', as shown in, "Address= network IP". When you are finished restarting the Firewall service, enter "Firewall-cmd--list-all" again to see the firewall policy.

At this point, the configuration of this machine as a router has been completed. Enter a virtual machine that requires networking.

The virtual machine is configured as follows:

1, configure the virtual machine's IP and the native is in the same network segment, the virtual machine IP as shown in this article is "172.25.254.102".

2. Enter "Route-n" to view the virtual machine gateway, for example, to set the gateway to native IP.

3, after the setup is complete, try to use the "ping" command, ping the native IP and network IP, the display and the local computer and the network is connected.

4, ping "www.baidu.com" found unable to connect, which means that although the network is connected but unable to access the domain name. You need to set the gateway "192.168.43.1" that DNS is automatically assigned to natively.

Once the above configuration is complete, the input "ping www.baidu.com" discovery is connected, which means the virtual machine is ready to go online. Problem solving for virtual machine networking.

Because the above firewall policy is used temporarily, you need to delete the previous policy after the use is complete, delete the method as shown, first close "Masquerade", and then delete the previously edited "rule family=" IPv4 "source address=192.168.43.28 Masquerade ", restart the Firewall service after completion.

Linux beginner-Virtual machine Networking Chapter

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.