BBB&RTL8188CUS搭建wifi AP 问题整理
1.nl80211 not found.
root@beaglebone:~# iw list
nl80211 not found.
解决: 需加载mac80211模块, 参考
http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=479321
http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git
sudo modprobe mac80211
2.wlan0: error fetching interface information: Device not found
插上无线网卡后能识别并且挂载, 但是通过ifconfig看不到对应的网卡名
root@beaglebone:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
root@beaglebone:/data/packages/wifi-reset#
root@beaglebone:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 88:c2:55:6c:1e:ed
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:40
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:56 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5224 (5.1 KiB) TX bytes:5224 (5.1 KiB)
usb0 Link encap:Ethernet HWaddr 88:c2:55:6c:1e:e0
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
root@beaglebone:/data/packages/wifi-reset# ifconfig wlan0
wlan0: error fetching interface information: Device not found
解决: 需加载对应的驱动, 如RTL5370 RTL8188,而RTL8188系列可以通过8192cu
驱动来使用
sudo modprobe 8192cu
参考: https://github.com/desflynn/realtek-8192cu-concurrent-softAP#bring-up-code
3.FATAL: Module iwlwifi not found
root@beaglebone:~# uname -a
Linux beaglebone 3.8.13-bone80 #1 SMP Wed Jun 15 17:03:55 UTC 2016 armv7l GNU/Linux
root@beaglebone:sudo modprobe iwlwifi
FATAL: Module iwlwifi not found
该版本内核并没有自带iwlwifi驱动,需要自行编译; 后来也没用到这个模块, 也就不再深究。
4.ifup: interface wlan0 already configured
root@beaglebone:~# ifup wlan0
ifup: interface wlan0 already configured
说明wlan0已经启用; 重启过程一般先ifdown再ifup
5.nl80211 driver initialization failed.
root@beaglebone:~# sudo hostapd -d /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
Could not open file /sys/class/net/wlan0/phy80211/name: No such file or directory
netlink: Operstate: linkmode=0, operstate=6
nl80211: Set mode ifindex 4 iftype 2 (STATION)
nl80211: Failed to set interface 4 to mode 2: -19 (No such device)
nl80211: Try mode change after setting interface down
nl80211: Set mode ifindex 4 iftype 2 (STATION)
nl80211: Failed to set interface 4 to mode 2: -19 (No such device)
nl80211: Interface mode change to 2 from 0 failed
nl80211 driver initialization failed.
解决:
1)/etc/hostapd/hostapd.conf中修改使用的driver类型
driver=nl80211
—> driver=rtl871xdrv
2)不能使用官方默认安装的hostapd版本, 具体参考–
http://blog.csdn.net/paul_c_v/article/details/41585483
6.modprobe: invalid option -- 'l'
modprobe: invalid option – ‘l’
这时modprobe版本的问题引起的, 具体参考:http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=469088
查看所有 你正使用中的 Linux kernel 版本 能夠提供的 Linux kernel Modules:
sudo ls -alRUv /lib/modules/$(uname -r)/kernel
7.ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
root@beaglebone:/data/packages# sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=4
l2_sock_recv==l2_sock_xmit=0x0x64648
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr 00:1d:43:20:01:74 and ssid 'moxiaomomo'
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid_ops
ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
可以参考上面第5点, 使用其他版本的hostapd; 具体操作也可以参考这个:
https://forums.adafruit.com/viewtopic.php?f=19&t=47716 中的这部分内容
cd /tmp
##sudo wget "ftp://95.130.192.218/cn/wlan/RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip" ##(without the quotes)
sudo wget "http://12244.wpc.azureedge.net/8012244/drivers/rtdrivers/cn/wlan/0001-RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip"
sudo unzip RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip
cd RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911
cd wpa_supplicant_hostapd
sudo tar -xvf wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz
cd wpa_supplicant_hostapd-0.8_rtw_r7475.20130812
cd hostapd
sudo make
sudo make install
sudo mv hostapd /usr/sbin/hostapd
sudo chown root.root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd
8. 创建AP后, 移动设备连接wifi时卡在 "正在获取IP地址"
原因是路由没有给移动设备分配ip地址, 一般需要开启dhcp服务;
修改/etc/dhcp/dhcpd.conf, 并且启动dhcpd
可参考: http://www.jb51.net/os/Ubuntu/388419.html
9.连上了热点, iphone手机却没有wifi信号, 安卓手机联网提示net:ERR_NAME_NOT_RESOLVED
dns配置出了问题, 首先在/etc/dhcp/dhcpd.conf中subnet部分 确定是否增加了配置option domain-name-servers
10.RTNETLINK answers: File exists
root@beaglebone:/data/packages/realtek-8192cu-concurrent-softAP# ifup wlan0
RTNETLINK answers: File exists
Failed to bring up wlan0.
应该是/etc/network/interfaces配置有问题,
auto wlan0
iface eth0 inet static
尝试去掉iface前的空格, 修改为:
auto wlan0
iface eth0 inet static
再尝试ifdown/ifup
11.配置wlan1为AP模式,wlan0为连接路由器模式
具体可参考:
https://github.com/desflynn/realtek-8192cu-concurrent-softAP#bring-up-code
https://pannzh.github.io/tech/2016/04/04/linux-kernel-forwarding.html
http://m.blog.csdn.net/article/details?id=51010243
http://blog.csdn.net/paul_c_v/article/details/41585483
http://www.cnblogs.com/buptmuye/p/3695790.html
以下为通过有线网卡转发的例子
配置路由转发
这里是参考:把树莓派配置成无线路由器 通过前面的配置过程,已经可以通过无线网络连接到Raspberry pi的无线网卡,但是还不能连接到互联网,
下一步就是让从无线网卡 wlan0 进来的数据 转发到 有线网卡 eth0上面 通过有线网卡连接网络接到互联网。
因为eth0是获取的动态ip,所以这里通过iptables来实现简单的路由转发。
输入命令
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo bash
iptables-save > /etc/iptables.up.rules
exit
输入
sudo nano /etc/network/if-pre-up.d/iptables
把下面两行复制粘贴到编辑窗口
#!/bin/bash
/sbin/iptables-restore < /etc/iptables.up.rules
保存退出,输入命令。
sudo chmod 755 /etc/network/if-pre-up.d/iptables
开启内核转发,输入命令。
sudo nano /etc/sysctl.conf
找到这里
# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
去掉 net.ipv4.ip_forward 前面的#,保存退出,输入命令。
sudo sysctl -p
配置完毕 通过无线连接上以后ping一下外网,可以通了,这样就可以把Raspberry Pi 当作路由器来用了。
12. ioctl[SIOCSIWAP]: Operation not permitted
root@beaglebone:~# wpa_supplicant -B -iwlan0 -Dwext -c/etc/wpa_supplicant.conf
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
暂时没找到原因和解决方案, 不过这个报警貌似也没造成什么影响。
================================
我的参考配置
root@beaglebone:~# cat /etc/dhcp/dhcpd.conf
#
# Sample configuration file for ISC dhcpd for Debian
#
#
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
#ddns-update-style none;
INTERFACES="wlan1";
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# This is a very basic subnet declaration for 192.168.12.*
subnet 192.168.12.0 netmask 255.255.255.0
{
range 192.168.12.10 192.168.12.50;
option routers 192.168.12.1;
#option domain-name-servers 202.99.166.4,202.99.160.68;
option domain-name-servers 8.8.8.8;
option broadcast-address 192.168.12.255;
}
root@beaglebone:~# cat /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="T-1000"
#psk="1qazxsw23edcvfr4!"
psk=39b26236550ac04b4026bfa020e54ec1308f5ee8ad726a846655d0f1a2e4a33d
}
root@beaglebone:~# cat /etc/hostapd/hostapd.conf
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
#WPA2 settings
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# CHANGE THE PASSPHRASE
wpa_passphrase=moxiaomomo
# Most modern wireless drivers in the kernel need driver=nl80211 byt we need rtl871xdrv
driver=rtl871xdrv
wme_enabled=1
wpa_group_rekey=86400
# set proper interface
interface=wlan1
bridge=lanbr0
hw_mode=g
# best channels are 1 6 11 14 (scan networks first to find which slot is free)
channel=11
# this is the network name
ssid=moxiaomomo
root@beaglebone:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
iface lo inet loopback
#
## The primary network interface
#iface eth0 inet static
# address 10.0.0.200
# netmask 255.255.255.0
# network 10.0.0.1
# gateway 10.0.0.1
# WiFi Setup Client on wlan0 + AP on wlan1
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.177
netmask 255.255.255.0
network 10.0.0.1
gateway 10.0.0.1
wpa-ssid "T-1000"
wpa-psk "1qazxsw23edcvfr4!"
allow-hotplug wlan1
iface wlan1 inet static
address 192.168.12.1
#Enable on startup
auto lo eth0
root@beaglebone:~# lsusb
Bus 001 Device 002: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
Bus 001 Device 004: ID 413c:2113 Dell Computer Corp.
root@beaglebone:~# lsmod
Module Size Used by
8192cu 417956 0
g_multi 50407 2
libcomposite 15028 1 g_multi
mac80211 424813 0
cfg80211 354018 1 mac80211
rfkill 16672 2 cfg80211
omap_rng 4062 0
xt_tcpudp 1841 3
xt_state 1217 2
iptable_filter 1479 1
ipt_MASQUERADE 1573 6
iptable_nat 2172 1
nf_conntrack_ipv4 11792 3
nf_defrag_ipv4 1324 1 nf_conntrack_ipv4
nf_nat_ipv4 3018 1 iptable_nat
nf_nat 13695 3 ipt_MASQUERADE,nf_nat_ipv4,iptable_nat
nf_conntrack 69347 6 ipt_MASQUERADE,nf_nat,xt_state,nf_nat_ipv4,iptable_nat,nf_conntrack_ipv4
ip_tables 9478 2 iptable_filter,iptable_nat
x_tables 15355 5 ip_tables,xt_tcpudp,ipt_MASQUERADE,xt_state,iptable_filter
rt5370sta 535960 0
root@beaglebone:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 88:c2:55:6c:1e:ed
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:40
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:56 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5224 (5.1 KiB) TX bytes:5224 (5.1 KiB)
usb0 Link encap:Ethernet HWaddr 88:c2:55:6c:1e:e0
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 00:1d:43:20:01:74
inet addr:10.0.0.177 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::21d:43ff:fe20:174/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21513 errors:0 dropped:22026 overruns:0 frame:0
TX packets:16167 errors:0 dropped:3 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:17389209 (16.5 MiB) TX bytes:2366728 (2.2 MiB)
wlan1 Link encap:Ethernet HWaddr 02:1d:43:20:01:74
inet addr:192.168.12.1 Bcast:192.168.12.255 Mask:255.255.255.0
inet6 addr: fe80::1d:43ff:fe20:174/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42859 errors:0 dropped:887 overruns:0 frame:0
TX packets:14727 errors:0 dropped:82 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2311874 (2.2 MiB) TX bytes:14785216 (14.1 MiB)
root@beaglebone:/data/packages/realtek-8192cu-concurrent-softAP# cat bring-up.sh
#Script to kill any existing hostapd, dhcps, wpa_supplicant, dhcpd, dnsmasq etc then bring up AP and Client
killall wpa_supplicant hostapd dnsmasq dhcpd udhcpd
ifdown wlan1
ifup wlan1
dhcpd -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid wlan1
hostapd -B /etc/hostapd/hostapd.conf
ifdown wlan0
wpa_supplicant -B -iwlan0 -Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf
ifup wlan0