0phoi5 Posted June 22, 2017 Posted June 22, 2017 Hi all, I am creating some shell scripts that occasionally need to use an external Alfa WiFi card, but not all of the time. Rather than leaving the Alfa card enabled constantly, I would like the script to bring the card online when it is required, and switch it back off when it is not. I have read various methods to do this online, but none seem definitive, so I would like to ask which method I should use. So far, I have seen suggestions of; Using WLAN# up and WLAN# down Disabling USB ports using Hub-CTRL Using hardware add-ons This or this (unknown what is being done here) Even people saying it's not possible. What would you suggest? Has anyone else had any luck with switching off and back on an Alfa Wifi Card from a Linux command line/script? I haven't yet played around, as I'm not at home, but I don't want to waste my time trying a method that won't work as well as something else. Thank you. Quote
Lord_KamOS Posted June 22, 2017 Posted June 22, 2017 18 minutes ago, haze1434 said: Using WLAN# up and WLAN# down This is the best solution for a bash script. Quote
digip Posted June 22, 2017 Posted June 22, 2017 For ifupdown, has to be setup for it, no? Why can't you just ifconfig wlan3 down/up, etc? Quote
dbum Posted June 22, 2017 Posted June 22, 2017 Are you looking to reduce power consumption (running off battery) or just looking to not have the wireless visible to the world? If you are not worried about any additional power consumption I think you would be fine just using ifconfig <interface> down / up in a shell script and be fine. If you are looking for power savings this may be a little more difficult (I'm assuming). Quote
0phoi5 Posted June 23, 2017 Author Posted June 23, 2017 (edited) 8 hours ago, dbum said: Are you looking to reduce power consumption (running off battery) or just looking to not have the wireless visible to the world? If you are not worried about any additional power consumption I think you would be fine just using ifconfig <interface> down / up in a shell script and be fine. If you are looking for power savings this may be a little more difficult (I'm assuming). Thanks. I'm looking to not have the wireless on at all, until I require it. At the moment, the Alfa external Wi-Fi card comes on as the Raspberry Pi boots up, and stays on until it shuts down. I don't use the Wi-Fi card all of the time, so rather than a 'low-power' mode when it's not in use, I'd like to literally just switch it off / supply it no power at all. Basically, the equivalent of unplugging the Wi-Fi card from the USB slot, but without having to physically unplug it. To give a better overview; This is for a home automation project where the Raspberry Pi will be switched on pretty much all of the time, but I don't want the external Wi-Fi antenna to be kicking out a signal all of the time, as it's a quite high powered antenna and I'd rather not sit in the radiation 24/7, no matter how small. For peace of mind, I'd rather just switch it off when not in use. Plus it also does use a battery back up, and if it's in this mode, the battery will be drained pretty quickly. Edited June 23, 2017 by haze1434 Quote
dbum Posted June 23, 2017 Posted June 23, 2017 Ok. So I did some testing this morning and this is what I came up with (it has been hectic at work today so I haven't been able to post until now): This was using an Alpha AWUS036 and monitoring the output (from another device - Mikrotik) and also monitoring the power going to the Raspberry pi 2 Here was my setup: My Pi, Mikrotik mAP and Alpha AWUS036 With antenna on - this was steady and remained the same through the duration (increasing txpower on antenna from 100mw to 1000mw) At 100mw At 1000mw So, just running the command 'ifconfig wlan0 down' Does turn off the Green LED on the device and monitor no longer registers Input power is greatly reduced (This stayed like this until turning the interface back on) It really appears that using ifconfig (could be used in whatever shell scripts you are using / cron / etc.) actually cuts the power to the device or at least puts it into a very low power state. Hope these findings help you on your journey! Quote
Lord_KamOS Posted June 23, 2017 Posted June 23, 2017 16 minutes ago, dbum said: Hope these findings help you on your journey! Could you measure it while running airodump-ng, or a deauth attack? Quote
dbum Posted June 23, 2017 Posted June 23, 2017 Sure, but it may be Sunday or Monday until I can get to it. Busy weekend planned. I'm not sure that ether measurements will vary too much. It seemed like the input power stayed fairly constant under different txpower (didn't try pushing huge amounts of data though) and I really don't think that would make the antenna power change. I can look into further as soon as I have a little time though. I had to cut testing short this morning to get to work :( Quote
dbum Posted June 23, 2017 Posted June 23, 2017 I guess that I could get a USB cable and cut it then run it through a multi-meter and see if any power is going through it after the ifconfig statement. I ran across this as well that I bet you could adapt to fully remove usb connectivity by controlling it with the Pi's IO pins https://www.cdw.com/shop/products/IOGEAR-2-Port-USB-2.0-Auto-Sharing-Switch/1691857.aspx?cm_cat=GoogleBase&cm_ite=1691857&cm_pla=NA-NA-IOR_US&cm_ven=acquirgy&ef_id=V4kGJwAABFSiqux7:20170623210440:s&gclid=CjwKEAjw-LLKBRCdhqmwtYmX93kSJAAORDM6sHEZfyy7JaDajuRpdaABZ3lpakpL5x3yovoyipiHIRoCK7jw_wcB&s_kwcid=AL!4223!3!198553132056!!!g!369923655287! Quote
digip Posted June 23, 2017 Posted June 23, 2017 1 hour ago, dbum said: I guess that I could get a USB cable and cut it then run it through a multi-meter and see if any power is going through it after the ifconfig statement. I ran across this as well that I bet you could adapt to fully remove usb connectivity by controlling it with the Pi's IO pins https://www.cdw.com/shop/products/IOGEAR-2-Port-USB-2.0-Auto-Sharing-Switch/1691857.aspx?cm_cat=GoogleBase&cm_ite=1691857&cm_pla=NA-NA-IOR_US&cm_ven=acquirgy&ef_id=V4kGJwAABFSiqux7:20170623210440:s&gclid=CjwKEAjw-LLKBRCdhqmwtYmX93kSJAAORDM6sHEZfyy7JaDajuRpdaABZ3lpakpL5x3yovoyipiHIRoCK7jw_wcB&s_kwcid=AL!4223!3!198553132056!!!g!369923655287! Could you also use the board to power off the USB port like an energy saver? Then power the port back on, which would also re-detect he hardware plugged in. I think that would also probably help reduce battery drain for devices looking to conserve, but you;d have to test that theory. Quote
dbum Posted June 23, 2017 Posted June 23, 2017 1 minute ago, digip said: Could you also use the board to power off the USB port like an energy saver? Then power the port back on, which would also re-detect he hardware plugged in. I think that would also probably help reduce battery drain for devices looking to conserve, but you;d have to test that theory. I can try that as well when I get my rig set up. Probably be Monday. Quote
0phoi5 Posted June 26, 2017 Author Posted June 26, 2017 On 23/06/2017 at 7:54 PM, dbum said: Hope these findings help you on your journey! Thank you for this, I didn't get a chance to play over the weekend (too much DIY to do around the house!). Much appreciated, and good info :) Quote
Daemon0x90 Posted July 25, 2017 Posted July 25, 2017 #!/bin/bash ifconfig wlan1 down ifconfig wlan2 down ifconfig wlan3 down exit 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.