终于搞定Linux下Wireless连接

其实没那么复杂,可是这两天网上找了N多教程总是不成功,百般无奈今天继续尝试,结果无意查看进程的时候发现NetworkManager进程居然在列,而且怎么也杀不掉。于是搜索了一下,ubuntu的NetworkManager评价并不是很好,估计就是这个manager产生冲突,于是直接删掉,然后用之前设置好的配置立马连接成功。。。

下面就记录下过程。。。

首先是删掉NetworkManager,执行命令

sudo apt-get remove network-manager

接着需要用到wpa_supplicant,我用的ubuntu 9.10默认已经安装了,如果没有则运行下面命令

sudo apt-get install wpasupplicant

安装好wpasupplicant,接着是配置wpa_supplicant.conf文件,该文件一般存放在/etc/wpa_supplicant/目录下,也可以自己修改

sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

我的配置文件内容如下:

ctrl_interface=/var/run/wpa_supplicant
network={
          ssid="your essid"
          psk="your security key"
          proto=WPA
          pairwise=TKIP
          key_mgmt=WPA-PSK
}

:wq 保存后退出,然后是配置/etc/network/interfaces文件,依然使用vi编辑器打开后写入如下内容:

auto wlan0
iface wlan0 inet dhcp

pre-up wpa_supplicant -B -Dwext -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
post-down killall -q wpa_supplicant

配置文件应该不难看懂,wlan0是我的无线网卡, dhcp是通过dhcp协议自动获取IP,如果是手动则改为如下:

auto wlan0
iface wlan0 inet static
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx

其余同上。
后面的pre-up就是通过wpasupplican加载配置文件当系统启动时,其中的wlan0是网卡,wext是通用的网卡驱动,应该可以满足大部分的网卡。

搞定以后保存退出,然后重启下网络就大功告成了!

sudo /etc/init.d/networking restart
This entry was posted in 学习笔记 and tagged , , , . Bookmark the permalink.

4 Responses to 终于搞定Linux下Wireless连接

  1. Qingxiong says:

    很强大!

  2. root9885 says:

    Listening on LPF/wlan1/00:e0:4c:92:2a:a2
    Sending on LPF/wlan1/00:e0:4c:92:2a:a2
    Sending on Socket/fallback
    DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 4
    DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 11
    DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 15
    DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 1
    No DHCPOFFERS received.
    No working leases in persistent database – sleeping.

    我这里连不上 想请教一下

Leave a Reply

Your email address will not be published. Required fields are marked *

12 + eighteen =