ubuntu 终端下配置无线网卡  

                   2009-11-30 16:26:48|  分类:          Ubuntu                          |举报        |字号 订阅      

转贴:http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=245226&start=0

注意:这个只是配置的教程,如果在无线网卡未被识别及驱动下不适用

测试环境: ubuntu 9.10 Server  +  D-LINK DWL-G520+A

###########/etc/network/interfaces###########

# The loopback network interface

auto lo
iface lo inet loopback

# The primary network interface

auto eth0 # or allow-hotplug eth0
iface eth0 inet static # or dhcp
hwaddress ether xx:xx:xx:xx:xx:xx
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx

# The wireless network interface

auto wlan0 # or allow-hotplug wlan0
iface wlan0 inet static # or dhcp
hwaddress ether xx:xx:xx:xx:xx:xx
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx
#WEP
wireless-essid xxxx
wireless-keymode open|restricted
wireless-key 12345|s:ascii
#WPA
wpa-ssid xxxx
wpa-driver wext
wpa-psk plaintext|hexadecimal

###############/etc/resolv.conf###############

# OpenDNS

nameserver 208.67.222.222
nameserver 208.67.220.220

##################MAC-Change##################

sudo ifconfig eth0 down

sudo ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

sudo ifconfig eth0 up

############Make it in operation#############

sudo /etc/init.d/networking restart

############Manual wired operation#############

ifconfig eth0 up

#DHCP

dhclient eth0

#Static

ifconfig eth0 xxx.xxx.xxx.xxx netmask 255.255.255.0

route add default gw xxx.xxx.xxx.xxx

##########Manual wireless operation###########


ifconfig wlan0 up

iwlist wlan0 scan

#No encryption

iwconfig wlan0 essid "ssid"

#WEP

iwconfig wlan0 essid "ssid" key 1234567890

iwconfig wlan0 essid "ssid" key s:asciikey

#WPA/WPA2

wpa_passphrase [ssid] [passphrase] >> /etc/wpa_supplicant.conf

wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf

#DHCP

dhclient wlan0

#Static

ifconfig wlan0 xxx.xxx.xxx.xxx netmask 255.255.255.0

route add default gw xxx.xxx.xxx.xxx

----------  以下是本人自己的记录 ----------
在安装完系统后,系统已经能驱动 D-LINK DWL-G520+A 了,只需按以下配置一下即下连接上AP
确认AP的加密设置为:
     模式:WPA Personal
     算法:TKIP

1) 先用 ifconfig -a 命令 show 一下网卡的设备号,一般第一张无线网卡为 wlan0
2) 在 /etc/network/interface 最后面加入
        auto wlan0                                         <-- 这里填入上面ifconfig -a查看到的设备号
        iface wlan0 inet dhcp                          <-- 这里可以用DHCP自动分配IP地址,也可以用static来自定义IP地址
        wpa-ssid xxxx                                    <--这里xxxx是你AP上设备的SSID ,注意大小写
        wpa-driver wext                                   <--告诉系统你用什么驱动,具体可问 google
        wpa-psk plaintext|hexadecimal             <-- 这里填你为无线AP设置好的密码,不是无线路由器的管理密码喔

如果无线AP的加密设置为:
     模式:WPA2 Personal
     算法:TKIP
    
     配置文件同上面的一样

     运行一下以下指令:
         wpa_passphrase [ssid] [passphrase] >> /etc/wpa_supplicant.conf
         wpa_supplicant -B -Dwext -i wlan0 -c /etc/wpa_supplicant.conf



如果不使用DHCP自动分配IP地址:

1)vi /etc/resolv.conf
2)加入两个ISP的DNS服务IP地址:
     nameserver 202.96.128.86
     nameserver 202.96.128.166
     [ 以上两个IP都是广东电信的DNS]