版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
配置ip地址
修改ifcfg-enp0s3文件红色内容(centos6是ifcfg-eth0文件)
[root@localhost ~]# cd /etc/sysconfig/network-scripts
[root@localhost network-scripts]# vi ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=b0a8a367-168b-401d-9c88-b91505f781dc
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.20.200
GATEWAY=192.168.20.1
NETMASK=255.255.255.0
NM_CONTROLLED=no
重启网络
[root@localhost network-scripts]# systemctl restart network
查看ip,使用ip add(最小化安装默认不会安装ifconfig命令,可使用# yum install net-tools -y 装好后就能使用ifconfig命令)
[root@localhost network-scripts]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:dc:75:9a brd ff:ff:ff:ff:ff:ff
inet 192.168.20.200/24 brd 192.168.20.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fedc:759a/64 scope link
valid_lft forever preferred_lft forever