CentOS 7 配置静态ip

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

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

    eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
    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<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    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 查看结果
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容