1、设置IP地址、网关
cp /etc/network/interfaces  /etc/network/interfacesbak   #备份原有配置文件
vi /etc/network/interfaces   #编辑网网卡配置文件
auto lo
auto eth0  #开机自动连接网络
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static   #static表示使用固定ip,dhcp表述使用动态ip
address 172.26.16.39
netmask 255.255.255.0
gateway 172.26.16.1
ONBOOT yes
broadcast 172.26.16.255
dns-nameservers 114.114.114.114


2、设置dns
cp  /etc/resolv.conf   /etc/resolv.confbak    #备份原有dns配置文件
vi /etc/resolv.conf   #编辑配置文件
nameserver 114.114.114.114   #设置首选dns
nameserver 8.8.4.4   #设置备用dns


3、重启网络
service networking restart   #重启网络
systemctl restart networking

ens33

#iface ens33 inet dhcp
auto ens33
allow-hotplug ens33
iface ens33 inet static
address 192.168.110.31
netmask 255.255.255.0
gateway 192.168.110.1
ONBOOT yes
broadcast 192.168.110.255
dns-nameservers 114.114.114.114