CentOS 7 配置静态ip

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

$ cd /etc/sysconfig/network-scripts/
$ ls

    eno16777736: flags=4163  mtu 1500
    inet 10.0.0.171  netmask 255.255.255.0  broadcast 10.0.0.255
    inet6 fe80::20c:29ff:fe1c:bdd6  prefixlen 64  scopeid 0x20
    ether 00:0c:29:1c:bd:d6  txqueuelen 1000  (Ethernet)
    RX packets 545820  bytes 51356930 (48.9 MiB)
    RX errors 0  dropped 82  overruns 0  frame 0
    TX packets 997901  bytes 111506438 (106.3 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    lo: flags=73  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10
    loop  txqueuelen 0  (Local Loopback)
    RX packets 1433  bytes 126772 (123.8 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 1433  bytes 126772 (123.8 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ vi  ifcfg-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

重启网络

$ systemctl restart network

$ ip addr  #或者ifconfig 查看结果

你可能感兴趣的:(CentOS 7 配置静态ip)