Script to turn wifi on/off
Is it possible to use a shell script to turn wifi off and on in Linux?
Due to a company security policy, we can't use wifi networking except between midnight and 1AM. I have a laptop with wifi, that has to be disabled most of the time. It does have an Ethernet connection to a router that is not connected to the Internet. The laptop needs to connect to the wireless network every day, do an update from the repositories and download some data. I want to create a cron job that runs at midnight and performs the following steps. (1) Enable wifi and connect to the wireless network. (2) Perform WGET operations to download a number of data files. Maybe do critical software updates. (3) Turn the wifi back off. (4) Reconnect to the local router via Ethernet. So the script needs to be able to manage the network connections automatically, and it needs to be able to run repeatedly. We're not setting the connections up for the first time, just enabling/disabling them. |
Quote:
You can use ifconfig to bring an interface up/down, and wget to do whatever else you need for downloading. Should be very easy to script...there are thousands of bash scripting tutorials you can find with a brief Google search. Where are you stuck?? What have you written so far? We're happy to help, but we WILL NOT write your script for you. |
Quote:
|
Quote:
Still confusing, though...hard to imagine a network that does NOT have an outbound connection somehow, or that wifi is only available for one hour a day, in the middle of the night, or there aren't some sort of provisions made at the company to let folks do updates during the day. ...unless this is homework..... |
Sorry, my fault: I should have explained better.
They have a disconnected subnet. There is a policy that the systems on the local network can't get data from the Internet except for a single data file that we need to download on a daily basis. There's also a policy that we can't have radio signals. The only exception is for an hour at night when it's OK to turn on the radio. But even then, the subnet stays disconnected and only this one laptop can perform this one update. So they have a wired router that is not connected to the Internet. I have an Ethernet cable from the laptop to that local router. I need to pull down a data file and the easiest thing seems to be, do it over wifi during the night when the wireless signal is available for one hour. While I'm at it, I can get updates. Here's a script I have worked out since I posted this question yesterday. It's intended to be run as root from a cron job. Code:
# turn off the ethernet interface. |
Quote:
Since this is for a company, I'd suggest you get with your data-security folks, and ask them to work with you, to provide a more bulletproof solution that fits in with your company's policies. Perhaps putting a dedicated VM Server in your DMZ, that does NOTHING but fetch such things, and acts as a repository would be in order. That would leave that machine in their control, and you could update as you see fit during the day. |
That's great advice. I'm going to mark this as solved.
|
All times are GMT -5. The time now is 11:51 PM. |