Site Tools


toggle_radio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
toggle_radio [2023/08/06 21:44] – [WiFi SSID-specific operation] -formatting hogwildtoggle_radio [2025/10/19 21:22] (current) – [Control Specific Wireless Chipsets (2.4/5GHz)] hogwild
Line 1: Line 1:
-====== Turning on/off WiFi radio elements from a script ======+====== Turn on/off WiFi Radio Elements from a Script ======
  
  
-===== Full Wireless operation =====+===== Full Wireless Operation =====
  
-If you want to enable/disable WiFi from the command line you can use the following system commands:+You can enable or disable WiFi from the command line using the following system commands:
  
  \\  \\
Line 12: Line 12:
 \\  ''/sbin/radio toggle'' \\  ''/sbin/radio toggle''
  
- \\  \\+ \\  \\ 
  
 **Force radio off:** **Force radio off:**
Line 18: Line 18:
  \\  ''/sbin/radio off''  \\  ''/sbin/radio off''
  
- \\  \\+ \\  \\ 
  
 **Force radio on:** **Force radio on:**
Line 24: Line 24:
  \\  ''/sbin/radio on''  \\  ''/sbin/radio on''
  
 + \\ 
  
-===== Specific Wireless chipset (2.4/5GHz) operations ===== 
  
-Modern routers come with two or more chipsets/WiFi interfaces. There is usually one 2.4GHz interface and one or more 5GHz interfaces. In certain case you might want to enable/disable a specific chipset via the command line.+===== Control Specific Wireless Chipsets (2.4/5GHz) ===== 
 + 
 +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 [[advanced-wlanvifs|Virtual Wireless]] page): Once you've identified the name of the appropriate radio interface (via the [[advanced-wlanvifs|Virtual Wireless]] page):
Line 33: Line 35:
  \\  \\
  
-{{:pasted:20221127-160308.png}}\\  \\+{{:pasted:20221127-160308.png?397}}\\  \\
  
-Do not blindly use this table. It is 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:+Do not blindly use this table. It'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 interfaceas follows:
  
-\\+\\ For example, using "eth1" in the above example:
  
-For example, using "eth1" in my the above example:+ \\ **Toggle:**
  
-**Verify interface state**+ \\ ''/sbin/radio toggle''
  
- \\  ''int=eth1''\\ '' [ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && echo "radio $int is off" || echo "radio $int is on"''+ \\  \\
  
- \\+**Verify interface state:**
  
- \\+ \\ ''int=eth1''
  
-**Toggle interface state**+ \\ '' [ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && echo "radio $int is off" || echo "radio $int is on"'' \\ 
  
-\\  ''int=eth1''\\ '' [ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && wl -i $int radio on || wl -i $int radio off''+ \\ \\ 
  
- \\+\\ **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**+ \\   \\ **Force interface off:**
  
- \\  ''int=eth1''\\ '' wl -i $int radio off''+ \\  ''int=eth1''\\ \\ '' wl -i $int radio off''
  
- \\+ \\ \\
  
- \\+**Force interface on:**
  
-**Force interface on**+ \\ ''int=eth1''\\ \\ '' wl -i $int radio on''
  
- \\ \\  ''int=eth1''\\ '' wl -i $int radio on''+ \\ \\
  
  
-===== WiFi SSID-specific operation =====+===== Control Specific WiFi SSIDs =====
  
-In some cases, you might want to just restrict access to only one specific SSID or change settings specific to only one WiFi interface.+In some cases, you might want to just restrict access to only one specific SSIDor change settings specific to only one WiFi interface.
  
 This can be achieved as follows: 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 [[advanced-wireless|Virtual Wireless]] menu. 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 [[advanced-wireless|Virtual Wireless]] menu.
  
-Virtual interfaces are always defined as: ''[ main wireless interface name ] + [.] + [number 0-3]''+Virtual interfaces are always defined as: [ main wireless interface name ] + [.] + [number 0-3]
  
-For example, on this router, in the Virtual Wireless menu, we can see the  2.4GHz interface named: "wl0.1".+ \\
  
- \\ \\ {{:pasted:20221127-163344.png}}+For example, in the Virtual Wireless menu on this router, you can see a 2.4GHz interface named "wl0.1":
  
- \\+ \\ \\ {{:pasted:20221127-163344.png?313}}
  
- \\+ \\ 
  
-Now, let's assume you want to turn off wl1.3 which is associated to SSID "test"+ \\ 
  
- \\ \\ {{:pasted:20221127-162109.png}}+Let's assume you want to control "wl1.3", associated with the SSID"test"
  
- \\+ \\ \\ {{:pasted:20221127-162109.png?908}}
  
- \\+ \\ 
  
-We could perform the following tasks:\\+ \\ 
  
-**Toggle interface state**\\+The commands below will perform these tasks.
  
-''int=wl1.3''\\ '' [ $(wl -i $int radio | grep -Eo [0-1]$-eq 1 ] && wl -i $int radio on || wl -i $int radio off''+(You may need to enter the command ''service wlgui restart'' after settings changes for them to take effect).
  
- \\+\\  \\
  
- \\+**Toggle interface state** \\ \\ 
  
-**Force Interface Off**+''int=wl1.3'' \\ \\ 
  
- \\ \\  ''int=wl1.3''\\ '' wl -i $int radio off''+'' [ $(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** **Force Interface On**
  
- \\ \\  ''int=wl1.3''\\ '' wl -i $int radio 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''
  
  \\  \\
 + \\ 
 +
 +==== Specific WiFi SSID Operation ====
 +
 +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''
  
-==== Wireless SSID specific operation ====+ \\ \\ 
  
-Let's say, as it often happens), a specific SSID you have defined is operational on multiple interfaces/sub-interfaces, you can disable the SSID everywhere as follow:\\+**Force On** \\ \\ 
  
-**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 on; done''
-''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''+ \\  
 + \\ 
toggle_radio.1691354655.txt.gz · Last modified: by hogwild