GeorgeYang'Blog

my technology blog

树莓派B+开启无线ap

阅读:750 创建时间:17-04-19 12:03:40 tags:raspberry

hostapd方式

  • 准备工作

    sudo apt-get update sudo apt-get install hostapd udhcpd

  • 启用自动分配ip

udhcpd主要为连接到WiFi的设备自动分配IP地址的,当然你也可以换用你所熟悉的软件。

配置udhcpd,编辑/etc/udhcpd.conf,主要内容如下:

 start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
 end 192.168.42.20
 interface wlan0 # The device uDHCP listens on.
 remaining yes
 opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
 opt subnet 255.255.255.0
 opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
 opt lease 864000 # 10 day DHCP lease time in seconds

接下来编辑/etc/default/udhcpd并且将下面这行注释掉,以使DHCP Server正常工作:

 #DHCPD_ENABLED="no"
  • 配置AP参数

    sudo nano /etc/hostapd/hostapd.conf

输入以下内容

 interface=wlan0
 driver=nl80211
 ssid=Raspberry_AP
 hw_mode=g
 channel=6
 macaddr_acl=0
 auth_algs=1
 ignore_broadcast_ssid=0
 wpa=2
 wpa_passphrase=12345678
 wpa_key_mgmt=WPA-PSK
 wpa_pairwise=TKIP
 rsn_pairwise=CCMP
  • 启动

    sudo hostapd /etc/hostapd/hostapd.conf

    如果成功,打印类似信息: root@wsn-laptop:sudo hostapd /etc/hostapd/hostapd.conf Configuration file: hostapd.conf
    Using interface wlan0 with hwaddr 00:22:5f:85:e7:a7 and ssid 'Raspberry_AP'

create_ap方式

  • 准备工作

    git clone https://github.com/oblique/create_ap cd create_ap make install

  • 开始启动

    sudo create_ap wlan0 eth0 热点名 密码

    create_ap --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase

    如果出现验证失败问题,请加上-w 2选项 sudo create_ap -w 2 --no-virt wlp2s0 enp3s0 name password

    sudo create_ap -w 2 --no-virt wlan0 eth0 pi3 123456789.

参考

http://blog.csdn.net/xukai871105/article/details/42497097/

http://wangye.org/blog/archives/845/

http://blog.csdn.net/yyplc/article/details/7301974

https://github.com/oblique/create_ap/issues/23