1)centos root用户下修改/etc/sysconfig/network-scripts/ifcfg-ens33文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
ens33就网卡名,可能不一样
BOOTPROTO=static
ONBOOT=yes
IPADDR="192.168.1.61"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.1"
DNS1="192.168.1.1"
DNS2="114.114.114.114"
2)ubuntu sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.22
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1