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
Next revisionBoth sides next revision
toggle_radio [2023/08/06 20:39] – [Turning on/off radio elements from script] hogwildtoggle_radio [2023/08/06 21:44] – [WiFi SSID-specific operation] -formatting hogwild
Line 1: Line 1:
-====== Turning on/off radio elements from a script ======+====== Turning 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 system command:+If you want to enable/disable WiFi from the command line you can use the following system commands:
  
-**Toggle**\\ + \\
-''/sbin/radio toggle''+
  
-**Force off**\\ +**Toggle:**
-''/sbin/radio off''+
  
-**Force on**\\ +\\  ''/sbin/radio toggle''
-''/sbin/radio on''+
  
 + \\  \\
  
-===== Wireless chipset (2.4/5GHz) specific operation =====+**Force radio off:**
  
-Modern routers come with 2 or more chipsets, there's usually 1x 2.4GHz and 1x (or more) 5GHz chipset. In some certain case you might want to enable/disable a specifi chipset from the command line. Once you have identified the  name of your radio interface (the [[advanced-wlanvifs|Virtual Wireless]] page is a good starting point) + \\  ''/sbin/radio off''
  
-{{:pasted:20221127-160308.png}}\\ + \\  \\
-Do not blindly use this table. Check what it says on your router as it might be different. FOr full chipset operation we refer to the ethX name reference of the interface. Once you have the correct name (I'm using eth1 in my example here below), you can check the status of your wireless interface as follow:+
  
-**Verify**\\ +**Force radio on:**
-''int=eth1\\ +
-[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && echo "radio $int is off" || echo "radio $int is on"''+
  
-**Toggle**\\ + \\  ''/sbin/radio on''
-''int=eth1\\  +
-[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && wl -i $int radio on || wl -i $int radio off''+
  
-**Force off**\\ 
-''int=eth1\\ 
-wl -i $int radio off'' 
  
-**Force on**\\ +===== Specific Wireless chipset (2.4/5GHz) operations =====
-''int=eth1\\ +
-wl -i $int radio on''+
  
-===== Wireless SSID specific operation =====+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.
  
-There might be cases where you don't want to affect the full radio chipset but rather restrict access to a specific SSID. This is achieved as follow: +Once you've identified the name of the appropriate radio interface (via the [[advanced-wlanvifs|Virtual Wireless]] page):
-- Identify the SSID virtual interface you want to affect. Remember virtual interfaces are always defined as [ main wireless interface name ] + [.] + [a number 0-3] so e.g. "wl0.1". The full list of wireless interfaces available on your router and the all their sub-interfaces once again can be found under [[advanced-wlanvifs|Virtual Wireless]] e.g.\\ +
-{{:pasted:20221127-163344.png}}+
  
-Now let's assume you want to turn off wl1.3 which is associated to SSID "test"\\ + \\
-{{:pasted:20221127-162109.png}}+
  
-Let's perform the following:\\+{{:pasted:20221127-160308.png}}\\  \\
  
-**Toggle**\\+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:
  
-''int=wl1.3\\  +\\
-[ $(wl -i $int radio | grep -Eo [0-1]$) -eq 1 ] && wl -i $int radio on || wl -i $int radio off''+
  
-**Force Off**\\ +For example, using "eth1" in my the above example: 
-''int=wl1.3\\ + 
-wl -i $int radio off''+**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'' 
 + 
 + 
 +===== WiFi SSID-specific operation ===== 
 + 
 +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 [[advanced-wireless|Virtual Wireless]] menu. 
 + 
 +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}} 
 + 
 + \\ 
 + 
 + \\ 
 + 
 +Now, let's assume you want to turn off wl1.3 which is associated to SSID "test" 
 + 
 + \\ \\ {{:pasted:20221127-162109.png}} 
 + 
 + \\ 
 + 
 + \\ 
 + 
 +We could perform the following tasks:\\ 
 + 
 +**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'' 
 + 
 + \\ 
 + 
 + \\
  
-**Force On**\\ 
-''int=wl1.3\\ 
-wl -i $int radio on'' 
  
 ==== Wireless SSID specific operation ==== ==== Wireless SSID specific operation ====
toggle_radio.txt · Last modified: 2023/08/06 21:49 by hogwild