您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)Linux下如何配置無(wú)線網(wǎng)絡(luò),小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
1. 安裝 wireless_tools 和 madwifi
pacman -S wireless_tools madwifi
2. 查看網(wǎng)卡狀態(tài)
lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 002: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse Bus 001 Device 003: ID 0cf3:7015 Atheros Communications, Inc.
在USB接口001/003上檢測(cè)到網(wǎng)卡。
iwconfig lo no wireless extensions. eth0 no wireless extensions. wlan0 IEEE 802.11bgn ESSID:off/any Mode:Managed Access Point: Not-Associated Tx-Power=0 dBm Retry long limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:off
無(wú)線網(wǎng)卡為 wlan0
3. 激活網(wǎng)卡
ifconfig wlan0 up
因?yàn)槲业木W(wǎng)卡必需要先激活才能掃描,否則下一步scan會(huì)出現(xiàn)錯(cuò)誤:wlan0 Interface doesn’t support scanning.
4. 掃描網(wǎng)絡(luò)
iwlist wlan0 scan wlan0 Scan completed : Cell 01 - Address: 54:E6:FC:22:E1:D2 Channel:1 Frequency:2.412 GHz (Channel 1) Quality=53/70 Signal level=-57 dBm Encryption key:on ESSID:"TP-LINK_22E1D2" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s 9 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=000000292a41bd80 Extra: Last beacon: 960ms ago IE: Unknown: 000E54502D4C494E4B5F323245314432 IE: Unknown: 010882848B960C121824 IE: Unknown: 030101 IE: IEEE 802.11i/WPA2 Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK IE: WPA Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK
發(fā)現(xiàn)WPA2-PSK/WPA-PSK 加密網(wǎng)絡(luò) TP-LINK_22E1D2,因?yàn)榧用芊绞綖?WPA-PSK 所以得用 wpa_supplicant 而不能使用 iwconfig wlan0 key xxx 形式,iwconfig key方式適用于WEP。
5. 配置 wpa_supplicant
新建文件 /etc/my_wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant network={ ssid="TP-LINK_22E1D2" psk="密碼" }
因?yàn)槿渴褂媚J(rèn)配置,所以配置文件非常簡(jiǎn)單。
6. 連接wlan0到網(wǎng)絡(luò),并以daemon方式運(yùn)行
wpa_supplicant -B -i wlan0 -c /etc/my_wpa_supplicant.conf -B Background 在后臺(tái)以daemon 運(yùn)行 -i interface -c 配置文件
7. 設(shè)置IP地址
ifconfig wlan0 192.168.1.131
ifconfig 查看狀態(tài)
wlan0 Link encap:Ethernet HWaddr 54:E6:FC:03:0D:6B inet addr:192.168.1.131 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:95 errors:0 dropped:0 overruns:0 frame:0 TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:32434 (31.6 Kb) TX bytes:576 (576.0 b)
8. 加入網(wǎng)關(guān)到路由
我的網(wǎng)關(guān)的是192.168.1.1,添加通過(guò)wlan0訪問(wèn)的網(wǎng)關(guān)
route add default gw 192.168.1.1 dev wlan0
查看狀態(tài)
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 wlan0 default 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
9. 設(shè)置完畢。
以后上線只需運(yùn)行以下
即可wpa_supplicant -B -i wlan0 -c /etc/my_wpa_supplicant.conf ifconfig wlan0 192.168.1.131 route add default gw 192.168.1.1 dev wlan0
10. 相關(guān)
關(guān)閉連接
wpa_cli terminate
連接狀態(tài)
wpa_cli status
關(guān)于“Linux下如何配置無(wú)線網(wǎng)絡(luò)”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。