1、编辑/etc/network/interface,添加如下内容
# interfaces(5) file used by ifup(8) and ifdown(8)
#auto lo
#iface lo inet loopback
#The primary network interface
auto ens33
iface ens33 inet static
address 192.168.111.203
netmask 255.255.255.0
gateway 192.168.111.1
2、配置dns,编辑/etc/resolve.conf,添加如下内容
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 114.114.114.114
nameserver 8.8.8.8
注意:此dns在系统重启后会失效,如果要永久保存可通过以下两种办法:
方法1)编辑/etc/resolvconf/resolv.conf.d/base,添加如下内容
nameserver 114.114.114.114
nameserver 8.8.8.8
方法2)编辑/etc/network/interface,添加如下内容
# interfaces(5) file used by ifup(8) and ifdown(8)
#auto lo
#iface lo inet loopback
#The primary network interface
auto ens33
iface ens33 inet static
address 192.168.111.203
netmask 255.255.255.0
gateway 192.168.111.1
dns-nameserver 114.114.114.114 8.8.8.8
3、重启网络/etc/init.d/networking restart,如果不管用则重启系统
来源:CSDN
作者:万年路口站
链接:https://blog.csdn.net/alen_work185/article/details/79423553