打开/etc/network/interfaces文件:
# interfaces(5) file used by ifup(8) and ifdown(8)# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
source interfaces.d/eth0
然后在/etc/network/interfaces.d目录下创建eth0文件,eth0文件内容如下:
auto eth0
iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
gateway 192.168.1.2
dns-nameservers 8.8.8.8
运行下面两个命令,使得IP和DNS生效: