**The title is Ubuntu16.04, but it is estimated to be applicable to 18.x. **
First enter ifconfig
to view the network card name,
sudo vi /etc/network/interfaces
The most annoying thing is that different Linux versions have different configuration files. For example, the file location and name of CentOS and Ubuntu are different.
default:
The most commonly used, static IP is generally configured in the virtual machine, because I want to connect to Ubuntu in the virtual machine through ssh.
The modification is as follows: The following ens33
needs to be changed to the name of your own network card, which is the red circle information in the first step above. The ip address and mask gateway can be configured reasonably by themselves. Remember wq! Save and exit.
auto ens33
iface ens33 inet static
address 192.168.184.8
netmask 255.255.255.0
gateway 192.168.184.2
dns-nameservers 114.114.114.114
How to configure IP address and gateway reasonably? Look at the virtual network configuration of the VM:
Open VM: Edit | Virtual Network Editor
If you want to configure dynamic IP, the following content is sufficient:
auto ens33
iface ens33 inet dhcp
dns-nameservers 114.114.114.114
Note that the above network card (
ens33
) is written as your own network card name. Remember wq! Save and exit.
reboot
Restart the computer to make the configuration take effect
Type ifconfig
**Link via xshell: **
**Successfully configured! ! **
Recommended Posts