Recently, in the process of writing a project on vm, you need to connect mysql on the virtual machine through Navicat on windows. it is found that the Ubuntu 16.04 system IP under the virtual machine is different every time you restart the virtual machine, resulting in the original Navicat configured connection can not be made.Use. So think of the need to configure a system in the VM will not change the ip, through the Internet to find relevant information, and according to their own practice, now will sort out the notes.
You can configure static IP for VM virtual machines in a handover manner, but because the cluster will be better with VAT configuration, NAT is recommended.
1. Share network of host network card to VMnet8
Find [Network] and [Network and Sharing Center] and [Change Adapter Settings] and [Change Adapter Settings] and] GT on the desktop; right-click on the network card currently used by the machine, and I’m using wireless here, so select [Wireless Network Connection] and right-click [Properties] and [GT] and] gt.[share] –> select the VMnet8 NIC in the selection box.
2.View the IP allocated by the host to the VMnet8 network adapter.
Command line input: ipconfig
3. Edit virtual network on VM
Open the VM software –> edit [–>]; [virtual network editor]
4. View valid IP range
Open the VM software –> edit [–>]; [virtual network editor]
5.Modifying the network adapter of the virtual machine
Open VM software –> [virtual machine] –> [settings]
6.View the name of the virtual machine’s network adapter.
VM terminal input: IP route show
7.Configuring static IP
The virtual machine terminal input: sudo GEDIT /etc/network/interfaces, and fill in the following contents
Remarks:dnsIn addition to the file configured in Step 7, the server can be configured separately in another file, as follows
- The virtual machine terminal input: sudo GEDIT /etc/resolv.conf, and then fill in the following contents
extend:More DNS please check http://dns.ip.cn/
8.Restart the network
Restart the virtual machine or restart the NIC: sudo /etc/init.d/networking restart
9.test
Open the virtual machine terminal, Ping address at random, see if Ping can be connected, such as: Ping www.baidu.com