Abstract: Original source https://peijie-sh.github.io welcome to reprint, keep the abstract, thank you!

According to the method of the Internet to try, there are always a few steps wrong, repeatedly tried several times, finally successful, make notes.

The environment

I’m running Windows 7 (it doesn’t matter) and have Ubuntu 16.04 LTS 64-bit virtual machine installed on my native VMWare. Want to use Xshell to operate local virtual machines in Windows 7.

Set the method

Configure the VMware network environment

After VMware is installed by default, three virtual network environments are created:

  • VMnet0: bridge network
  • VMnet1: Host – only
  • VMnet8 :NAT

Where, NAT means that Ubuntu installed in VMWware will be in a subnet. VMware uses network address translation to access the Internet through the IP address of a physical machine. We chose NAT to implement the configuration of Ubuntu’s static IP address.

  1. Open VMware and choose Edit > Virtual Network Editor at the top to open virtual Network Editor:
  2. Delete VMnet0 and VMnet1 and retain only VMnet8.
  3. Then, remove “Assign to vm using local DHCP service award IP address” from the following figure:
  4. The subnet IP address is 192.168.8.0 and the subnet mask is 255.255.255.0. Therefore, in Ubuntu, you can set the IP address to 192.168.8. X, and x ranges from 1 to 255.
  5. Select “NAT Settings” to open the NAT Settings panel:

    Check your gateway address. For example, the gateway address is 192.168.8.2.

  6. Finally, in the VMWare VIRTUAL Machine management window, choose Edit VM Settings of Ubuntu to open the Ubuntu virtual machine Settings screen.

Select the network adapter, and then make sure the network connection is VMnet8 in “Custom” (NAT mode) :

VMWare is configured.

Ubuntu Network Settings

  1. In the upper right corner of the Ubuntu desktop, click on the network icon and select “Edit Connections” :

  2. Click the Edit button, in the IPv4Settings TAB, select Manual for Method, and click Add to Edit the IP address

    Set the IP address as follows: IP: 192.168.8.100 Subnet mask: 255.255.255.0 Gateway: 192.168.8.2 Save the Settings.

  3. Finally, click on the network icon in the upper right corner of the Ubuntu desktop and select Disconnect. Then open the menu again, select Connect, you can Connect to the Internet.

The terminal configuration

Open Terminal and configure static IP addresses

sudo vi /etc/network/interfaces

Read as follows:

Auto LO iface LO inet loopback Auto ENS33 iface ENS33 inet static Address 192.168.8.100 Netmask 255.255.255.0 Gateway 192.168.8.2Copy the code

For clarification, starting with ubuntu15, the nic name eth0 was changed to ens33.

Configure DNS

sudo vi /etc/resolv.conf

Fill it in with DNS, like Ali’s DNS: 223.5.5.5

Nameserver 223.5.5.5Copy the code

The setting is complete.

conclusion

Run sudo /etc/init.d/networking restart to restart the network. However, we have previously selected the customized NAT mode for vmware, so the above command will fail to be executed. As long as vmware changes to the bridge mode and directly connects to the physical network, check the copy physical network connection state and execute it.

However, this would cause the VIRTUAL machine to be disconnected from the network, so I finally changed the connection mode to the custom NAT mode, and found that the host could SSH to the local VIRTUAL machine at this time.