版本ubuntu1604
展示全部网卡
$ ifconfig -a
查看其中有个网卡名字为ens160
启用网卡ens160(对应的网卡名)
$ ifconfig ens160 up
目标目录:/etc/network/interfaces
vim interfaces
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto 网卡名
#iface ens160 inet dhcp
auto 网卡名
iface 网卡名 inet static
address 192.168.175.96
netmask 255.255.255.0
gateway 192.168.175.254
dns-nameserver 202.102.152.3
按照上面的文字对应的修改成自己需要的IP地址就可以了。
修改完成之后记得重启网络的服务。
方法一、network
利用root帐户
#service network restart
或者/etc/init.d/networking restart
方法二、ifdown/ifup
#ifdown eth0
#ifup eth0
最后使用ping工具来检测一下就可以了。