---
title: "Ubuntu下设置固定IP地址(转)"
author: "上官车月"
date: "2013-02-25T16:33:33Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu-ip"
draft: false
lastmod: "2013-02-25T16:33:33Z"
id: 1814782
url: "https://guomingjun.iteye.com/blog/1814782"
---

运行如下命令：

$ sudo vi /etc/network/**interfaces**

修改auto eth0下的相关内容为如下：

```
auto eth0 
#iface eth0 inet dhcp -- 这个是自动ip的设置 
iface eth0 inet static 
address  [ip地址] 
netmask  [子网掩码] 
gateway  [网关]
```

运行如下命令重启网络服务：

$ sudo /etc/init.d/**networking restart**