服务器网卡默认配置文件:/etc/sysconfig/network-scripts/ 下,一般为 ifcfg-eth0 、ifcfg-eth1等。
修改命令为:vi /etc/sysconfig/network-scripts/ifcfg-eth0 (centos7 网卡名为 ifcfg-eno16777736),修改BOOTPROTO ,添加IPADDR、NETMASK、GATEWAY。
ONBOOT=yes (yes no 重启网卡是否激活网卡设备)
BOOTPROTO=static (none、static、bootp、dhcp,不适用协议、静态分配、BOOTP协议、DHCP协议)
重启网卡:/etc/init.d/network restart
查看命令:ifconfig 或 ip addr show
centos 7 使用 ip addr list/show 或者安装 net-tools 工具(yum install net -tools -y)