设置静态ip

一。修改文件设置静态ip

     1.  打开网卡配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

    2. 修改如下

DEVICE="eth0"                             # 网卡名称,对应ifcfg-eth0
BOOTPROTO="static"                        # static 为静态,dhcp 为动态获取
HWADDR="00:0C:29:4E:E8:AC"                # 网卡地址
ONBOOT="yes"                              # 可启动网卡,如果为 no 就禁用网卡
TYPE="Ethernet"                           # 以太网
IPADDR="10.20.0.101"                      # 本机ip
NETMASK="255.255.255.0"                   # 子网掩码
GATEWAY="10.20.0.1"                       # 网关,不上网可以不要
DNS="10.20.0.1" # 设置DNS

    3 .重启网络服务

[root@localhost ~]# service network restart

 

posted @ 2018-03-06 20:09  Python++  阅读(331)  评论(0编辑  收藏  举报