CentOS7配置静态IP地址

CentOS 7 配置静态IP地址

  1. 切换到网卡列表目录

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

network

一般第一个就是你的网卡,若是服务器,可能会有多个以ifcfg-em开头的网卡,分别对应服务器的网卡接口,在这里我的网卡为ifcfg-eth0

  1. 编辑网卡

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    $vi ifcfg-eth0

    BOOTPROTO=none
    ONBOOT=yes
    # IP地址
    IPADDR=102.168.1.100
    # 子网掩码
    PREFIX=24
    # 网关地址
    GATEWAY=192.168.1.1
    # 设置DNS地址
    DNS1=202.96.134.133
    DNS2=8.8.8.8

ipconfig

退出vi,使用:wq命令

  1. 保存退出,重启网络服务

    1
    $service network restart

若成功,则出现如下提示
success

Author: entercoder1993
Link: http://entercoder.com/2018/09/12/CentOS7配置静态IP地址/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.