先使用命令查看无线网卡的名字:
ifconfig
结果如下:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.123.165 netmask 255.255.255.0 broadcast 192.168.123.255
inet6 fe80::8ced:f8c8:81e:4e78 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:5f:7f:23 txqueuelen 1000 (Ethernet)
RX packets 241360939 bytes 36052043728 (33.5 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 533542201 bytes 738621286186 (687.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 269480 bytes 11338213 (10.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 269480 bytes 11338213 (10.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether b8:27:eb:0a:2a:76 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
其中的wlan0就是树莓派自带的无线网卡。
打开无线网卡的监听模式:
ifconfig wlan0 mode monitor
会报错:
mode: Unknown host
ifconfig: `--help' gives usage information.
使用如下命令查看无线网卡是否支持监听模式(monitor):
iw list
输出结果如下:
Supported interface modes:
* IBSS
* managed
* AP
* P2P-client
* P2P-GO
* P2P-device
我发现树莓派自带的无线网卡不支持监听模式(monitor)
然后我使用支持监听模式(monitor)的无线网卡,这类网卡有很多,我用的是8187L无线网卡。
然后使用命令
iw list
可以看出支持监听模式(monitor):
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* mesh point
开启监听模式(monitor):
ifconfig wlan1 down
iwconfig wlan1 mode monitor
ifconfig wlan1 up
查看是否成功开启监听模式(monitor):
iwconfig
结果如下,开启成功:
wlan1 IEEE 802.11 Mode:Monitor Frequency:2.412 GHz Tx-Power=30 dBm
Retry short long limit:2 RTS thr:off Fragment thr:off
Power Management:off