0

I am trying to run airodump in the background.. I wrote the following script thats called from /etc/rc.local:

#!/bin/bash

/usr/local/sbin/airmon-ng check kill >> /tmp/airmon-kill 2>&1
sleep 2
/usr/local/sbin/airmon-ng start wlan0  > /tmp/airmon-start 2>&1
sleep 2
/usr/local/sbin/airodump-ng wlan0mon --manufacturer --uptime --wps --output-format csv --write-interval 5 --write log  > /tmp/airmon-dump 2>&1&

When I run these commands as root from the terminal they work fine. When I run them from rc.local I get all kind of issues..

First the kill script.. this one seems to work fine since the output is:

Killing these processes:

  PID Name
 2294 dhcpcd

Next the start script... thats where I get an error that I don't get when I run it on the terminal myself:

PHY Interface   Driver      Chipset

phy0    mon.wlan0   rt2800usb   Ralink Technology, Corp. RT5370
phy0    wlan0       rt2800usb   Ralink Technology, Corp. RT5370

Error setting channel: command failed: Device or resource busy (-16)
Error -16 likely means your card was set back to station mode by something.
Removing non-monitor mon.wlan0 interface...

WARNING: unable to start monitor mode, please run "airmon-ng check kill"

Any ideas why the behaviour is so different? Both run as root (I checked that) and both run from bash. Why the different behaviour?

Will
  • 24,082
  • 14
  • 97
  • 108
Alex van Es
  • 1,141
  • 2
  • 15
  • 27

1 Answers1

0

Instead of putting it in rc.local, which, it appears to me, may run before networking is actually started, edit /etc/network/interfaces. Inside the definition for wlan0 (or whatever your wireless interface is named), add a post-up command:

iface wlan0 inet dhcp
    ...
    post-up /path/to/your/bash/script.sh

This will run your script after the wlan0 interface actually comes online.

Will
  • 24,082
  • 14
  • 97
  • 108