---
title: "ubuntu12.4网卡设置，自定义ip地址"
author: "weilingfeng98"
date: "2013-01-08T12:57:15Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu12-4-ip"
draft: false
lastmod: "2013-01-08T13:02:10Z"
id: 1766129
url: "https://weilingfeng98.iteye.com/blog/1766129"
---

上网搜索修改linux网络地址的文章，在ubuntu12.04版本都不能用，然后去utuntu12.04官网看了一下，找到了修改ip地址的方法，在这里总结一下，以便记忆
1.ubuntu12.04的网络设置文件

```java
vim /etc/network/interface 
```


```java
# The loopback network interface
auto lo  
iface lo inet loopback
```

加入下面的配置

```java
# The primary network interface 
auto eth0
iface eth0 inet static
address 10.12.146.84
netmask 255.255.255.0
gateway 10.12.146.1 
```

加入后查看该文件可可以看到

```java
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo  
iface lo inet loopback
         
# The primary network interface 
auto eth0
iface eth0 inet static
address 10.12.146.84
netmask 255.255.255.0
gateway 10.12.146.1 
```


加入该配置后网络还不能生效，需执行该命令

```java
/etc/init.d/netwoking restart
```


2.修改dns配置
如果设置ip后不能连接外网，则可能需要修改dns配置（当然如果你配置了桥接方式）
执行命令
```java
 vim /etc/resolv.conf 
```


加入如下dns配置

```java
nameserver 8.8.8.8
nameserver 8.8.4.4
```

这两个地址是google提供dns解析地址
到目前为止linux网络配置就完成了

ps:这了还有一篇介绍的比较详细，贴出来<http://www.01happy.com/ubuntu-12-04-network-setting/>