After installing the ubuntu-16.04.7-server-amd64 version, this is the server version of Ubuntu, not the desktop version, please pay attention.
A server edition installation allows you to permanently install Ubuntu on a computer to be used as a server. It will not install a GUI.
log into the system
View network device names
ifconfig -a
Edit network card configuration file
sudo vim /etc/network/interfaces
Enter user password
Add the following content
auto ens33 #网卡名称
iface ens33 inet static #网卡获取网络方式静态
address 10.0.0.7 #IP地址
netmask 255.0.0.0 #子网掩码
gateway 10.0.0.2 #网关
dns-nameservers 119.29.29.29 223.5.5.5 #DNS服务器2个,可写1个
After saving and exiting, restart the network
sudo systemctl restart networking.service
No error is reported, indicating that the network service restarted successfully
Perform a network connectivity test
ping -c 4 baidu.com
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
Send 4 packets, receive 4 packets, 0% packet loss, time 3006ms
The time depends on the network delay
dns-nameserver will write the corresponding DNS server address to the /etc/resolv.conf domain name resolution file
sudo vim /etc/resolv.conf
Note: Editing /etc/resolv.conf directly, rewriting the DNS restart in it will fail.
The solution is: edit the network card configuration file as above, define it in the network card, and then this file will automatically generate DNS configuration according to the definition of the network card configuration file