You can enable or disable WiFi from the command line using the following system commands:
Toggle:
/sbin/radio toggle
Force radio off:
/sbin/radio off
Force radio on:
/sbin/radio on
Modern routers come with two or more chipsets/WiFi interfaces. Typically, there is one 2.4GHz interface and one or more 5GHz interfaces. In certain cases, you might want to control a specific chipset via the command line interface.
Once you've identified the name of the appropriate radio interface (via the Virtual Wireless page):
Do not blindly use this table. It's only an example. Router interface names may vary. For full chipset operation, refer to the “ethX” name reference of your interface(s). Once you have the correct names, you can check the status of your WiFi interface, as follows:
For example, using “eth1” in the above example:
Toggle:
/sbin/radio toggle
Verify interface state:
int=eth1
[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && echo “radio $int is off” || echo “radio $int is on”
Toggle interface state:
int=eth1
[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && wl -i $int radio on || wl -i $int radio off
Force interface off:
int=eth1
wl -i $int radio off
Force interface on:
int=eth1
wl -i $int radio on
In some cases, you might want to just restrict access to only one specific SSID, or change settings specific to only one WiFi interface.
This can be achieved as follows:
First, identify the SSID virtual interface you want to control. The full list of WiFi interfaces on your router and all its sub-interfaces can be found in the Virtual Wireless menu.
Virtual interfaces are always defined as: [ main wireless interface name ] + [.] + [number 0-3]
For example, in the Virtual Wireless menu on this router, you can see a 2.4GHz interface named “wl0.1”:
Let's assume you want to control “wl1.3”, associated with the SSID: “test”
The commands below will perform these tasks.
(You may need to enter the command service wlgui restart after settings changes for them to take effect).
Toggle interface state
int=wl1.3
[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && wl -i $int radio on || wl -i $int radio off
Force Interface Off
int=wl1.3
wl -i $int radio off
Force Interface On
int=wl1.3
wl -i $int radio on
The iplink command is another reliable tool, allowing you to disable any interface or change its MAC address.
For example:
Take down an interface
iplink set wl1.3 down
Bring up an interface:
iplink set wl1.3 up
Often, a specific defined SSID operates on multiple interfaces/sub-interfaces. You can disable that SSID on all interfaces everywhere, as follows:
Force Off
SSID=MYCOOLSSID
nvram show | grep ssid | grep $SSID | while read line; do wl -i $(echo $line | cut -d“=” -f1 | cut -d_ -f1 ) radio off; done
Force On
SSID=MYCOOLSSID
nvram show | grep ssid | grep $SSID | while read line; do wl -i $(echo $line | cut -d“=” -f1 | cut -d_ -f1 ) radio on; done