分享

整理:在pcDuino上建立wifi热点

 xiaofenglib 2013-09-06
本帖最后由 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、执行下面的指令就可以将内核跟换掉
   $mount /dev/nanda  /boot
   $cp ./uImage  /boot  -f
   $cp ./evb.bin  /boot  -f

6、这时候pcDuino上面已经自带了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的时候会出现错误。具体的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
安装完成之后。执行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

保存之后执行$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,可以看出已经 ignore,这说明这个错误不重要,重要的话她会停止。
这里需要说明一下,执行hostapd   -dd  /etc/hostapd.conf  它是不会停止的,他会一直添加随机的添加数字去加解密,我们需要手动的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;   #网关,即wlan3IP地址
   option domain-name-servers 8.8.8.8;
}

重启hostapd,参数-Bhostapd后台运行。
$sudo killall hostapd
$hostapd -B /etc/hostapd.conf
设置无线网络的IP
$ifconfig wlan3 192.168.0.1
启动dhcp-server
$ dhcpd wlan3  -pf   /var/run/dhcp-server/dhcpd.pid
打开IP转发
$echo 1 >/proc/sys/net/ipv4/ip_forward
设置NAT
$sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

其实在wifiAP目录下已经将上面的指令做成了一个脚本文件,我们只需要运行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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多