---
title: "linux 设置ip"
author: "dchaoxiong"
date: "2009-03-26T16:05:01Z"
tags: []
slug: "linux-ip"
draft: false
lastmod: "2009-03-26T16:05:01Z"
id: 355628
url: "https://diaoge.iteye.com/blog/355628"
---

步骤1：设置配置文件

在/etc/sysconfig/network-scripts/  下编辑文件 ifcfg-eth0

将其内容改为：

    DEVICE=eth0

    BOOTPROTO=static

    IPADDR=10.168.218.5   注：你想为本机设置的IP

    NETMASK=255.2540.0.0   注：IP对应的子网掩码

    GATEWAY=10.168.218.1   注：网关

    HWADDR=00：03：47：2C    注：网卡编号，这个不要去修改它。

    ONBOOT=yes

    TYPE=ETNERNET

    保存

步骤2：重启网卡

重启网卡有两种方法：

方法1：在命令行运行：/sbin/ifdown eth0

               /sbin/ifup   eth0

方法2：在命令行运行：/etc/init.d/network restart