Enable monitoring mode for RTL8188CUS

转载:
https://raspberrypi.stackexchange.com/questions/36747/enable-monitoring-mode-for-rtl8188cus-via-usb-on-raspbian


I am trying to enable monitoring mode for a USB wifi dongle with the RTL8188CUS chipset on a raspberry pi model b+ (or any raspberry pi for that matter).

$ lsusb
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; Invalid argument.

According to github/raspberrypi/linux/issues/369, you need to enable the rtlwifi/rtl8192cu kernel module that is included with the kernel distribution but not compiled. This requires minor modifications to some files as diff'ed below in 'STEP 2'.

The USB issue mentioned in that thread has been resolved as of 4.1.6+, so the rtlwifi driver should work.

Steps to recreate on a fresh raspberry pi (model B+)...

STEP 0: Update existing modules and kernel to latest

$ sudo apt-get update
$ sudo rpi-update
$ uname -a
Linux raspberrypi 4.1.7+ #815 PREEMPT Thu Sep 17 17:59:24 BST 2015 armv6l GNU/Linux

STEP 1: Get the raspbian kernel source and add missing dependencies

$ git clone --depth=1 https://github.com/raspberrypi/linux
$ sudo apt-get install bc lshw

STEP 2: Enable the rtlwifi (kernel) drivers for RTL8188CUS (RTL8192)

edit linux/drivers/net/wireless/Kconfig
-#source "drivers/net/wireless/rtlwifi/Kconfig"
-source "drivers/net/wireless/rtl8192cu/Kconfig"
+source "drivers/net/wireless/rtlwifi/Kconfig"
+#source "drivers/net/wireless/rtl8192cu/Kconfig"

edit linux/drivers/net/wireless/Makefile
-#obj-$(CONFIG_RTLWIFI)         += rtlwifi/
+obj-$(CONFIG_RTLWIFI)          += rtlwifi/

STEP 3: Compile and install kernel (took many hours)

Summarized from kernel building documentation .

$ cd linux
$ KERNEL=kernel
$ make bcmrpi_defconfig

$ make zImage modules dtbs
$ sudo make modules_install
$ sudo cp arch/arm/boot/dts/*.dtb /boot/
$ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
$ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
$ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img

STEP 4: Reboot

$ sudo reboot

STEP 5: Check that the rtlwifi/rtl8192cu module is loaded

$ lsmod | fgrep rtl8192cu
rtl8192cu             100806  0 
rtl_usb                14781  1 rtl8192cu
rtl8192c_common        72091  1 rtl8192cu
rtlwifi               101122  3 rtl_usb,rtl8192c_common,rtl8192cu
mac80211              623281  3 rtl_usb,rtlwifi,rtl8192cu
$
$ lshw
  *-network:0
       description: Ethernet interface
       physical id: 1
       bus info: usb@1:1.3
       logical name: wlan0
       serial: 00:0b:81:94:e9:a3
       capabilities: ethernet physical
       configuration: broadcast=yes driver=rtl8192cu driverversion=4.1.7+ firmware=N/A link=no multicast=yes

STEP 6: Try to activate monitoring mode

$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
    SET failed on device wlan0 ; Operation not supported.

What did i miss?
Issue 369 seems to indicate that it can work with the rtlwifi driver?

share improve this question
 
 
This, sir, was extremely helpful. I followed the steps pretty much exactly, and it worked like a charm. –  Alex Nichol  Feb 14 '16 at 23:07
 
With all due respect and bonus points for perseverance, IMHO this is also rather cumbersome. See here, you can get a wifi dongle with a chipset that supports monitor mode out of the box, for under 5 USD including shipping. –  RolfBly  Jun 11 '17 at 21:05 

2 Answers

up vote 7 down vote accepted

Turns out the steps to recompile and load the rtlwifi module are correct. The problem is iwconfig not working to enable/determine monitoring mode in this situation.

Instead, I used iw as outlined by Steven Gordon and it worked.

To summarize:

STEP 6b: List the physical network interfaces available

$ iw dev

STEP 7: Determine if the physical interface supports monitoring mode

$ iw phy phy0 info
... lots of stuff ...
Supported interface modes:
     * IBSS
     * managed
     * AP
     * AP/VLAN
     * monitor
     * mesh point
     * P2P-client
     * P2P-GO
... lots more stuff ...

STEP 8: Add a monitoring interface to that physical card

You need to explicitly add a 'monitoring' interface for the hardware you have.

$ sudo iw phy phy0 interface add mon0 type monitor

STEP 8: Start monitoring

In my case, I'm using tshark to facilitate monitoring, displaying a few useful fields rather than a lot of noise.

$ sudo apt-get install tshark
$ sudo tshark -i mon0 -f 'broadcast' -T fields -e frame.time_epoch -e wlan.sa -e radiotap.dbm_antsignal -e wlan.fc.type -e wlan.fc.subtype

Done.

share improve this answer
 
 
Your link is broken, you're missing the last few characters: sandilands.info/sgordon/capturing-wifi-in-monitor-mode-with-‌​iw (I tried to edit your post but apparently edits must be at least 6 characters...) –  Ted Mielczarek Aug 26 '16 at 10:39
 
I don't understand what to do in Step #2 // need help. –  Ray Kodiak  Sep 16 '16 at 4:17
 
Inside the git repo you cloned in step 1 ('linux' directory)... Edit the file 'linux/drivers/net/wireless/Kconfig', comment out the 2 lines with rtl8192cu in them by adding a '#' to the beginning of the line. Edit the file 'linux/drivers/net/wireless/Makefile', comment out the 1 line with rtl8192cu, uncomment the line with rtlwifi. –  Matt M  Sep 16 '16 at 18:59 

Great instructions. Thank you. Couple of more things I needed to do...

  1. When I rebooted my raspberry pi 3 with the new image (4.9.13-v7+), lsmod did list the rtl8192cu though the rtl8192cu directory was in /lib/modules/4.9.13-v7+/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8192cu Solution: I had to do a sudo modprobe rtl8192cu

  2. iwconfig jsut says "No wireless extensions" even for the interfaces that are actively connected to an AP. I am using iw instead. See instructions in http://linuxwireless.org/en/users/Documentation/iw/__v41.html


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值