centos7不能再通过setup命令来设置ip了,但可以通过修改网卡配置文件来设置ip
在/etc/sysconfig/network-scripts目录下找到网卡配置文件,修改之前内容如下
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=2b3d4748-e104-407c-b5a6-2458da589b4d
DEVICE=eno16777736
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
修改之后,配置如下
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=2b3d4748-e104-407c-b5a6-2458da589b4d
DEVICE=eno16777736
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
HWADDR=00:0C:29:8E:14:B1
IPADDR=192.168.1.232
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=202.96.64.68
最后重启网络服务
service network restart