ubuntu 16.04 vm virtual machine nat configure static ip

Foreword: This problem has troubled me for a long time. I know the static ip of the bridge. However, it is better to configure the cluster in the way of nat. (The communication between clients in the nat mode does not go through the router), so it would be better to switch to the nat mode.

To use the nat method to set a static ip, a considerable amount of computer network knowledge is required.

First, check whether your host's network card shares the network to the virtual network card vmnet8?  Open Network Sharing Center ---> Change Adapter Settings and see the picture below and right click on the network card you are using. I use wireless. So right click on the wireless network connection -> Properties -> Sharing - select the vmnet8 network card in the selection box. This function is that the wireless network card and the virtual machine's network card are connected to the host and the virtual machine through the vmnet8 virtual network card to communicate. This knowledge is important.



。  

1 First of all, you need to know that the ip assigned by the host to the vmnet8 network card is shown in the figure below.

This ip is the gateway when the virtual machine is configured with a static ip, remember! ! ! ! ! ! ! This is an important point.

2 Open the vm software - "Edit - "Virtual Network Editor


Then don't rush to click OK, click NAT settings and set it up like this


 Do you think it's set up? ? ? Not yet, because you don't know the valid IP address range divided by the virtual dhcp server of the vm, so this step, knowledge view, does not need to be set. Or open the virtual network editor (remember that knowledge view is not a setting, and finally click Cancel.)

 

3 Make virtual machine configuration file settings

My system is ubuntu 16.04 lts, ​​the centos system can find the corresponding network card configuration file.

kong@root:sudo /etc/network/interfaces  


Make the following modifications


4 Make dns settings  

kong@root:sudo  vim /etc/resolvconf/resolvconf.d/head

 Write nameserver 8.8.8.8 in, save and exit, and restart the network card. or restart the virtual machine

Then ping www.baidu.com to see if you can ping

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324822751&siteId=291194637