OpenWrt Forum Archive

Topic: How do I restart wireless interface from command line?

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Wifi on my router dies every few days. Apparently, it's a known problem - at least many people complain about it. The simple solution is to disable WiFi, and then enable it again - keeps it going for another few days. So, I want to put this in cron and do it every night, rather than wait until it dies and do it manually. ifconfig shows me that there is wlan0 interface:

wlan0     Link encap:Ethernet  HWaddr 10:xx:xx
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3352 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4858 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:32
          RX bytes:509676 (497.7 KiB)  TX bytes:4598806 (4.3 MiB)

However, running ifdown wlan0 returns an error:

# ifdown wlan0
Interface wlan0 not found

Is there a different name that I should use?

Router Model is Buffalo WZR-HP-G300NH2 and I am running the latest Firmware (Attitude Adjustment 12.09-beta2 / LuCI 0.11 Branch (0.11+svn9402)

Thanks

(Last edited by ymhee_bcex on 22 Nov 2012, 20:27)

just "wifi"

easy hah !XDD


Guys, take some times to read the documents in wiki.
http://wiki.openwrt.org/doc/uci/wireless

(Last edited by johan666 on 22 Nov 2012, 20:35)

Tried that...

# ifdown wifi
Interface wifi not found

Also tried radio0.network1 (I gleaned that from tracing what LuCi sends to the server), radio0 (which is the wifi-device value in /etc/config/wireless), and buffalo (which is my SSID).

I wish it were easy... wink
And of course, I read wiki before I asked...

(Last edited by ymhee_bcex on 22 Nov 2012, 20:39)

Just "wifi" command!!

Thanks. And yes, I missed the section on start/stop in wiki (actually - I saw it but I thought it applied to UCI and now obsolete).

At the risk of looking complete idiot... how do I redirect wifi's output? When I run it from command line, I get

Configuration file: /var/run/hostapd-phy0.conf
Using interface wlan0 with hwaddr 10:6f:xx:xx and ssid "myssid"

However, if I redirect

wifi >wifi.txt

I get an empty file wifi.txt and nothing on the screen, either.

I do see a line in syslog

crond[4799]: crond: USER root pid 32110 cmd wifi

but would be great to see some confirmation that the program completed successfully

(Last edited by ymhee_bcex on 25 Nov 2012, 19:49)

ymhee_bcex wrote:

I do see a line in syslog

crond[4799]: crond: USER root pid 32110 cmd wifi

but would be great to see some confirmation that the program completed successfully

Reason for the empty file is that the startup msg comes from a script or program triggered by switching the IF up, not from the 'wifi' script itself. But you could use uci to check for the IF state afterwards:

uci -p /tmp/state get wireless.@wifi-iface[0].up

returns 1 if the IF is up and running.

The discussion might have continued from here.