命令:vim /etc/network/interfaces
nano /etc/network/interfaces /etc/network/interfacesbak #备份原有配置文件
nano /etc/network/interfaces #编辑网网卡配置文件
auto lo
auto ens33 #开机自动连接网络
iface lo inet loopback
allow-hotplug ens33
iface ens33inet static #static表示使用固定ip,dhcp表述使用动态ip
address 192.168.2.22 #设置ip地址
netmask 255.255.255.0 #设置子网掩码
gateway 192.168.2.2 #设置网关
#network 192.168.2.0
#broadcast 192.168.2.255
ctrl+o #保存配置
ctrl+x #退出
设置dns
ctrl+o #保存配置
ctrl+x #退出
重启网络