Linux Tutorial: How to configure Linux systems network environment in a virtual machine?

For many Linux beginner students, most of them choose to use a virtual machine to expand the learning. You can easily experiment with, modify, test, without fear of problems, you can easily toss! Big deal for a virtual machine, the original system are not affected. But because the entity is not pc machine, use inevitably limited. If the configuration is not good, late-stage development will be subject to its tired!

For example, many programs have to use the database! MySQL, Redis. Establish a connection with them, especially in remote, you must specify the IP and port. How to configure a virtual machine can make windows and Linux connectivity, easy access to external network but it does not change frequently?

preparation stage

This short article is to explain the Vmware virtual machine Ubuntu operating system, configuration, graphical network environment. Vmware version of the text used is 15.1.0. Ubuntu system version 18.04.

First, before starting the configuration, you need a ready well in advance, and master a prior knowledge.

l Preparation: Make sure the system has been successfully installed Ubuntu ssh. You can use aptitude command to see.

l Preliminaries: After successfully installing Vmware virtual machine, our pc can be found in two network cards. Physical and virtual network adapter card VMnet8. NIC physical connection WLAN. Virtual LAN VMnet8, connect the internal LAN. Make sure they are enabled. If not enabled, the icon shown in the figure below, right-click and select "Enable" button.

Bridge Mode

Configure the bridge mode, the most simple! With the router or switch automatically assign IP, to reach windows, Linux visit each other.

The first step, open the configuration page Vmware virtual machine. Select the bridging mode.

The second step click the Ubuntu system, "Network" icon, select "Wired setting", click on the pop-up page of the "+" sign to add a wired connection.

The third step is to set a new name to add a wired connection, so you can see the name to know Italian. IPv4 then use its default attribute. Confirmation click on the "Add" button.

The fourth step, select, connect the new configuration. You can see the new configuration corresponding to the generation of Linux IP address on the page.

Alternatively, the terminal Linux system, type "ifconfig" command.

Use "ipconfig" command in the terminal windows, windows to view the IP address of the system:

test. Both systems use the IP address of the terminal, each ping. Because the bridge mode to use, can be understood as, your virtual machine, to deceive the router, the router make you think of the virtual machine is a physical machine, and assigned a unique IP address to it.

After the test passes, windows and Linux systems can make use of routers, each visit! And if the route can be connected to an external network, the two systems can be free and independent range web.

However, this connection has some problem!

1. Linux is set to automatically obtain IP, when the network environment changes, or other PC join the network environment, when certain conditions are met, the IP address may change. So, we write the program, all related IP network settings need to be modified, reconfigured.

2. If the network environment setup dial-up connection permissions! Such as: teaching classroom Chi Chuan's blog! Then you need two different network connections account, in order to ensure the normal windows-Linux environment to enable two networks to communicate.

We change the configuration of NAT another way, we can solve this problem!

NAT mode

Vmware Virtual Machine to us to provide the "Virtual Network Editor" using NAT mode, you can solve the above problem, the configuration is slightly more complex, but using them is very convenient! Windows-Linux can support a fixed IP Internet at the same time, both systems can access the external network (of course, to ensure that the home network unimpeded oh). We together look.

First, the configuration page Vmware virtual machine instead "NAT mode."

Next, we need to modify "Virtual Network Editor," the. Select and open.

Modify "NAT settings", according to their preferences, add a set. Figure: Here adds "192.168.6.2" NAT settings as a gateway.

Back to the Linux system, click on the "Network" icon, select "Wired setting", click on the pop-up page of the "+" sign, and then re-add a wired connection, this time we manually set the Linux IP address:

Give us a new connection configuration, since an easily recognizable name. What does not matter, mainly to easily find, at a glance.

Next, the "automatic" to "manual", fill in the custom IP address. Note, IP addresses here must be "NAT settings" in the network segment in front! And, according to previously specified gateway fill. At the same time set the DNS service. Specifies right, top right, click "Add."

Next, in the icon we just specify the use of the new connection. At the same time again to reconfirm the IP address, routing, DNS information is correct.

Confirmation, began to test the network is unobstructed. NDS can take Google's first try. You can ping, then that access the Internet no problem. You can access the windows?

Note that here we need again in the windows of the terminal, type "ipconfig" command to check the windows to get VMnet8 corresponding IP address. Linux windows communicate with each other, need to use this IP.

The IP for Windows is automatically assigned. Because we specify "192.168.6.2" for the gateway. The "192.168.6.1" is automatically designated as available IP. Try, can ping pass.

You can then try Linux external network. Such as Baidu, Taobao, Jingdong! At this point our Linux by means of a Windows network to access external network, so long as the network open Windows, Linux systems can access freely, and can communicate directly with the Windows.

After this configuration, since we are using a manual IP address, unless the network environment has undergone major changes, otherwise IP does not change. All IP addresses used in the program's code, not frequently changed during the test, learning to use it a lot easier!

Published 682 original articles · won praise 1391 · Views 1.71 million +

Guess you like

Origin blog.csdn.net/itcast_cn/article/details/105204109