CentOS|CentOS 7 配置静态ip

编辑网卡的配置文件即可。

$ cd /etc/sysconfig/network-scripts/ $ lseno16777736: flags=4163mtu 1500 inet 10.0.0.171netmask 255.255.255.0broadcast 10.0.0.255 inet6 fe80::20c:29ff:fe1c:bdd6prefixlen 64scopeid 0x20 ether 00:0c:29:1c:bd:d6txqueuelen 1000(Ethernet) RX packets 545820bytes 51356930 (48.9 MiB) RX errors 0dropped 82overruns 0frame 0 TX packets 997901bytes 111506438 (106.3 MiB) TX errors 0dropped 0 overruns 0carrier 0collisions 0lo: flags=73mtu 65536 inet 127.0.0.1netmask 255.0.0.0 inet6 ::1prefixlen 128scopeid 0x10 looptxqueuelen 0(Local Loopback) RX packets 1433bytes 126772 (123.8 KiB) RX errors 0dropped 0overruns 0frame 0 TX packets 1433bytes 126772 (123.8 KiB) TX errors 0dropped 0 overruns 0carrier 0collisions 0$ viifcfg-eno16777736

修改
#BOOTPROTO="dhcp" #ONBOOT="no" BOOTPROTO="static" ONBOOT="yes" GATEWAY=10.0.0.1 DNS1=10.0.0.1 #使用NetworkManager NETMASK=255.255.255.0 IPADDR=10.0.0.185

【CentOS|CentOS 7 配置静态ip】重启网络
$ systemctl restart network$ ip addr#或者ifconfig 查看结果

    推荐阅读