2

I have openWrt installed on a TP-Link TL-WA901N/ND v3. I don't have luci package installed because I don't have enough space, so I can only do thing via cli.

What I'm trying to achieve is to create a mon0 interface at startup and run tcpdump on it. I've created a file in /etc/init.d and named it monitor. The monitor file contains the following

#!/bin/sh /etc/rc.common

#to start after /etc/init.d/network is started and stop after it stopped
START=99
STOP=1

start(){
    #tried with and without the following two lines
    include /lib/network
    scan_interfaces

    iw phy phy0 interface add mon0 type monitor
    ifconfig mon0 up
    echo "mon0 is up!"
}
stop(){
    ifconfig mon0 down
    iw mon0 del
    echo "mon0 is down!"
}

then I run the following

/etc/init.d/monitor enable

and in /etc/rc.d I can see S99monitor and K1monitor but when I reboot, I can't see the mon0 interface created when I do ifconfig.

This works if I manually start it with

/etc/init.d/monitor start

I've also tried adding the command above to /etc/rc.local but nothing changed.

What am I doing wrong?

  • Did you update-rc.d monitor default? In Debian it needs special header, i don't know what in dd-wrt – Krzysztof Stasiak Jun 13 '17 at 7:08
0

I guess you forgot to add the

boot(){
start
}

section

  • 2
    can you elaborate how a boot() function would solve the problem? – Jeff Schaller Mar 30 '16 at 18:53
  • You wrote it works if you do "/etc/init.d/monitor start" but it doesn't automaticaly do it after reboot. So you need to add the boot section in /etc/init.d/monitor – max Apr 1 '16 at 11:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.