---
title: "ubuntu配置多网卡访问网络"
author: "conkeyn"
date: "2012-10-08T15:15:17Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu"
draft: false
lastmod: "2012-10-08T15:32:23Z"
id: 1693657
url: "https://conkeyn.iteye.com/blog/1693657"
---

第一步：切换到root 用户下。

```
su root
```

 第二步：编辑网络配置文件

```
vi /etc/network/interfaces
```

 第三步：对/etc/network/interfaces增加以下内容

```
#默认的初始配置
auto lo
iface lo inet loopback

#后续添加
auto wlan1
iface wlan1 inet static
#指定无线网卡要连接的无线路由，指定无线路由的ssid
wireless-essid TP-LINK
#指定无线路由的密码
#wireless-key AAAAABBBBB
address 192.167.1.71
netmask 255.255.255.0
network 192.167.1.0
broadcast 192.167.1.255
gateway 192.167.1.1
nameserver 192.167.1.1
```

第四步：重启网络

```
/etc/init.d/networking restart
```

 第五步：添加路由。添加路由时需要指定要使用哪个网卡。

```
route add -net 10.46.0.0 netmask 255.255.0.0 gw 192.167.1.1 wlan1
```