0

I ran into a bit of a weird problem (or at least in my opinion it is).

When I execute the following command:

sudo iwconfig wlx00c0ca959fe2 mode monitor channel 1

Everything is fine, WLAN adapter is set to monitor mode on channel 1.

In order to "automate" this I created the following bash script:

#!/bin/bash

if [ "$1" != "" ] && [ "$2" != "" ]; then
    echo "Shutting down $1"
    echo "channel: $2"
    echo "wlan interface $1" 
    sudo ifconfig $1 down
    echo "Configuring monitor mode for $1 channel $2"
    sudo iwconfig $1 mode monitor channel $2
    echo "Powering on $1" 
    sudo ifconfig $1 up
else
    echo "No input parameter was given using wlx00c0ca959fe2 as default" 
    echo "Shutting down wlx00c0ca959fe2" 
    sudo ifconfig wlx00c0ca959fe2 down
    echo "Configuring monitor mode for wlx00c0ca959fe2 channel 11" 
    sudo iwconfig wlx00c0ca959fe2 mode monitor channel 11
    echo "Powering on wlx00c0ca959fe2" 
    sudo ifconfig wlx00c0ca959fe2 up
fi

Which works fine on my raspberryPi but gives the following error code on my laptop (Mint 19.1 cinnanmon).

sudo ./setMonitorMode.sh
No input parameter was given using wlx00c0ca959fe2 as default
Shutting down wlx00c0ca959fe2
Configuring monitor mode for wlx00c0ca959fe2 channel 11
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device wlx00c0ca959fe2 ; Device or resource busy.
Powering on wlx00c0ca959fe2

Does anyone have an idea what this is? Because I ran out of options /ideas haha.

Thanks in advance!

Kind regards, Kasper

edit:

with -x:

+ '[' wlx00c0ca959fe2 '!=' '' ']'
+ '[' 10 '!=' '' ']'
+ echo 'Shutting down wlx00c0ca959fe2'
Shutting down wlx00c0ca959fe2
+ echo 'channel: 10'
channel: 10
+ echo 'wlan interface wlx00c0ca959fe2'
wlan interface wlx00c0ca959fe2
+ sudo ifconfig wlx00c0ca959fe2 down
+ echo 'Configuring monitor mode for wlx00c0ca959fe2 channel 10'
Configuring monitor mode for wlx00c0ca959fe2 channel 10
+ sudo iwconfig wlx00c0ca959fe2 mode monitor channel 10
Error for wireless request "Set Frequency" (8B04) :
    SET failed on device wlx00c0ca959fe2 ; Device or resource busy.
+ echo 'Powering on wlx00c0ca959fe2'
Powering on wlx00c0ca959fe2
+ sudo ifconfig wlx00c0ca959fe2 up

I tried IP command as well, same result.

  • Hoi Kaspertje. Maybe you should try ip instead. ifconfig is in some recent linux versions left out. Is the interface really shut down? You can add -x to #!/bin/bash -x or just use set -x on the second line of the script and see what's happening. – Valentin Bajrami Jun 11 '19 at 13:26
  • Hi Valentin, Thank you for your quick response! I tried both of your solutions, unfortunately without result. Please see my updated post for more details. – kaspertje100 Jun 11 '19 at 13:46
  • Besides, when I manually input the commands: sudo ifconfig wlx00c0ca959fe2 down" and "sudo iwconfig wlx00c0ca959fe2 channel 10" and "sudo ifconfig wlx00c0ca959fe2 up" they do work without problems. – kaspertje100 Jun 11 '19 at 13:48
  • Tiny little update: I separated set monitor mode and channel into two commands. So now first monitor mode is set (which works) and then channel to N. Which gives the same error as is shown in the begin post. So the problem seems to be with setting the channel. – kaspertje100 Jun 11 '19 at 13:57
  • Kaspertje. Then you should strace the following sudo iwconfig wlx00c0ca959fe2 mode monitor channel 10. See what strace reveals. It is not the bash script, it is the command you are running that generates the error. – Valentin Bajrami Jun 12 '19 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.