本帖最后由 Viner 于 2013-9-3 11:13 編輯 1、下載更換內核需要的附件(wifiAP),到ubuntu目錄下。
2、刪除 /etc/modules/ 目錄下的 “3.4.29+”文件夾。
$sudo rm -rf /lib/modules/3.4.29+ 3、復制wifiAP目錄下的“3.4.292B.tar”到/lib/modules/
解壓文件
$sudo tar xvf 3.4.292B.tar 5、執(zhí)行下面的指令就可以將內核跟換掉
$mount /dev/nanda /boot
$cp ./uImage /boot -f
$cp ./evb.bin /boot -f 6、這時候pcDuino上面已經(jīng)自帶了rt5370驅動,但是那個是rt5370sta;只支持ad-hoc(點對點),
$vim /etc/moudules
注釋掉rt5370 ,然后重啟pcDuino
重啟后輸入:$sudo lsmod 查看內核加載信息是否如下:
Module Size Used by rt5370sta 617141 0 8192cu 537048 0 rt2800usb 11321 0 rt2800lib 40721 1 rt2800usb crc_ccitt 1094 1 rt2800lib rt2x00usb 7245 1 rt2800usb rt2x00lib 31040 3 rt2800usb,rt2800lib,rt2x00usb mali_drm 2087 1 drm 157060 2 mali_drm mac80211 257514 3 rt2800lib,rt2x00usb,rt2x00lib cfg80211 150671 2 rt2x00lib,mac80211 mali 91258 0 disp_ump 823 0 ump 44002 4 mali,disp_ump 7、由于我們在內核選擇的是一個系列,因此在我們使用的時候需要進行一些設置。
$sudo modprobe rt2800usb
$sudo -s $echo 148F 5370 > /sys/bus/usb/drivers/rt2800usb/new_id $modinfo rt2800usb
8、復制wifiAP中的rt2807.bin 到 /lib/firmware
這里輸入$ifconfig 查看wlan號,我這里看到的是:wlan3。然后輸入 $ifconfig wlan3 up
9、安裝hostapd:
$tar xvf hostapd-1.0.tar.bz2
$cd hostapd-1.0/hostapd
$vim defconfig (找到#CONFIG_IEEE80211N=y 去掉前面的#注釋)
修改之后:
$cp defconfig .config
$make
$make install
在make的時候會出現(xiàn)錯誤。具體的bug信息如下:
../src/drivers/driver_nl80211.c:19:31: fatal error: netlink/genl/genl.h: No such file or directory
compilation terminated. make: *** [../src/drivers/driver_nl80211.o] Error 1 這里要安裝一些庫。
$sudo apt-get install libnl-dev
$sudo apt-get install libssl-dev 安裝完成之后。執(zhí)行hostapd -v
$sudo hostapd -v
hostapd v1.0 User space daemon for IEEE 802.11 AP management, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator Copyright (c) 2002-2012, Jouni Malinen <http://www./mailto:j@w1.fi> and contributors 可以看到版本信息,說明安裝成功。 10、配置hostapd
$vim /etc/hostapd.conf內容如下:(注意我 $ifconfig 產看的是wlan3,所以里面寫上wlan3)
root@ubuntu:~# vim /etc/hostapd.conf
interface=wlan3 driver=nl80211 ssid=pcDuino hw_mode=g channel=11 dtim_period=1 rts_threshold=2347 fragm_threshold=2346 macaddr_acl=0 auth_algs=1 ieee80211n=0 wpa=2 wpa_passphrase=1234567890 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP 從配置文件可以看到我們要共享的wifi熱點的
名字:ssid=pcDuino
密碼:wpa_passphrase=1234567890
加密方式:wpa_key_mgmt=WPA-PSK
保存之后執(zhí)行$hostapd -dd /etc/hostapd.conf會打印一下信息。
root@ubuntu:~# hostapd -dd /etc/hostapd.conf
random: Trying to read entropy from /dev/random Configuration file: /etc/hostapd.conf nl80211: interface wlan3 in phy phy3 rfkill: initial event: idx=0 type=2 op=0 soft=0 hard=0 rfkill: initial event: idx=4 type=1 op=0 soft=0 hard=0 nl80211: Using driver-based off-channel TX nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress) nl80211: Register frame match - hexdump(len=1): 06 nl80211: Failed to register Action frame processing - ignore for now nl80211: Add own interface ifindex 23 nl80211: Set mode ifindex 23 iftype 3 (AP) nl80211: Create interface iftype 6 (MONITOR) Failed to create interface mon.wlan3: -23 (Too many open files in system) Try to remove and re-create mon.wlan3 nl80211: Remove interface ifindex=37 nl80211: Create interface iftype 6 (MONITOR) nl80211: New interface mon.wlan3 created: ifindex=38 nl80211: Add own interface ifindex 38 BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits) nl80211: Regulatory information - country=00 nl80211: 2402-2472 @ 40 MHz nl80211: 2457-2482 @ 40 MHz nl80211: 2474-2494 @ 20 MHz nl80211: 5170-5250 @ 40 MHz nl80211: 5735-5835 @ 40 MHz nl80211: Added 802.11b mode based on 802.11g information Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm 以上信息中有個nl80211: Failed to register Action frame processing - ignore for now,可以看出已經(jīng) ignore,這說明這個錯誤不重要,重要的話她會停止。
這里需要說明一下,執(zhí)行hostapd -dd /etc/hostapd.conf 它是不會停止的,他會一直添加隨機的添加數(shù)字去加解密,我們需要手動的Ctrl+C把他中斷掉。
11、安裝DHCP服務器
$sudo apt-get install dhcp3-server
完成之后需要配置dhcp服務器。
$vim /etc/dhcp/dhcpd.conf
在后面加上
subnet 192.168.0.0 netmask 255.255.255.0
{ range 192.168.0.2 192.168.0.10; option routers 192.168.0.1; #網(wǎng)關,即wlan3的IP地址 option domain-name-servers 8.8.8.8; } 重啟hostapd,參數(shù)-B是hostapd后臺運行。
$sudo killall hostapd
$hostapd -B /etc/hostapd.conf
設置無線網(wǎng)絡的IP
$ifconfig wlan3 192.168.0.1
啟動dhcp-server
$ dhcpd wlan3 -pf /var/run/dhcp-server/dhcpd.pid
打開IP轉發(fā)
$echo 1 >/proc/sys/net/ipv4/ip_forward
設置NAT
$sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
其實在wifiAP目錄下已經(jīng)將上面的指令做成了一個腳本文件,我們只需要運行wifiAP這個文件夾下名為 AP.sh的腳本文件就可以啟動wifi熱點,
打開可以看到AP.sh的內容為:(再次說明:wlan3為我當前查看到的)
#! /bin/sh
killall hostapd hostapd -B /etc/hostapd.conf
ifconfig wlan3 192.168.0.1 dhcpd wlan3 -pf /var/run/dhcp-server/dhcpd.pid echo 1 >/proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 附件下載:http://www./file/id_84090997184659544.htm
|
|
來自: xiaofenglib > 《pcDuino》