In the recent process of writing a project on a VM, you need to connect to MySQL on the virtual machine via navicat on Windows, and discover that the ubuntu16.04 system IP under each reboot of the virtual machine is different, causing the connection that was previously configured in Navicat to be unusable. So think of the need to configure a system in the VM will not change the IP, after the Internet to find relevant information, and according to their own practice, will now tidy up the notes.
Configuring a static IP for a VM virtual machine can use the handover, but the cluster is better because of the VAT configuration, so it is recommended to use NAT.
1. Share the network of the host network card to VMnet8
On the desktop, find "network"-"Network and Sharing Center"-"Change adapter Settings"-Right click on the network card currently used by the computer, I use wireless, so check "wireless network Connection" Right-click "Properties"-"shared"- In the selection box, select the VMNET8 network card.
2. View the IP assigned by the host to the VMnet8 NIC
Command line input: ipconfig
3. Edit the virtual network on the VM
Open the VM Software--"edit"--"virtual network editor"
4. View valid IP ranges
Open the VM Software--"edit"--"virtual network editor"
5. Modify the virtual machine's network adapter
Open the VM Software--"virtual machine" and "settings"
6. View the network card name of the virtual machine
Virtual machine terminal input: IP route Show
7. Configure static IP
Virtual machine terminal input: sudo gedit/etc/network/interfaces, then fill in the following content
Note:DNS server In addition to the configuration in the 7th step of the file, can also be configured separately in another file, as follows
- Virtual machine terminal input: sudo gedit/etc/resolv.conf, then fill in the following content
Extensions : More DNS See http://dns.ip.cn/
8. Restart the network
Restart the virtual machine or restart the network card: sudo/etc/init.d/networking restart
9. Testing
Open the virtual machine terminal, Ping an address to see if you can ping, such as: Ping www.baidu.com
ubuntu16.04 Configuration static IP (NAT mode) under VM virtual machine