Shell script to bring WWAN modem down and up?

I have a Sierra Wireless Compass 885 modem (aka AT&T Mercury) for connecting to the Internet via AT&T that works really well. I get over 6 Mb/s down and 5 Mb/s up, so I'm pretty happy with it. I'm going to be using a new Mac Mini with the Internet Sharing feature to share this connection with the rest of my network at home. Here's the thing: the modem seems to get randomly disconnected sometime after about 12-24 hours.

I'd like to run a shell script periodically to automatically disconnect and reconnect the WWAN modem. Can anyone give me any hints what commands or scripts I need to run in my shell script? Or is there a better way to do this, such as AppleScript or Automator? Basically, I want to automatically reset the WWAN modem every 12 hours.

Thanks very much in advance!

Mac Mini (2010), Mac OS X (10.6.4)

Posted on Oct 23, 2010 8:42 AM

Reply
4 replies

Oct 23, 2010 7:38 PM in response to stairway27

Cole Tierney said
Another idea would be to get an inexpensive router to handle multiple internet connections. I'm not suggesting this would solve your problem, but it might.

I strongly agree with Cole Tierney about getting a router and not using your Mac mini Internet Sharing.

While Internet Share is useful in a pinch, it is poor substitute for a real router.

First of all the WiFi encryption is WEP with can be cracked in under a minute.

If you have Macs WEP can use character passwords, but if you have PCs or Linux boxes, you will have to get the hexidecimal equivalent value and use that on the PCs and Linux boxes. Very annoying.

Because your Mac mini will be on the subnet created by your ISP assigned IP address, which will be different from the subnet created by Internet Sharing, it maybe difficult to actually use file sharing with your Mac mini. You mileage may vary.

A router between your ISP and your Mac mini would give you a hardware firewall. Directly attaching your Mac mini to the ISP's broadband modem means your Mac mini is exposed to all the dangers of the internet.

As for connecting/disconnecting to the ISP's broadband modem, you could do the following:

System Preferences -> Network -> Location -> Edit Locations
Create a new location and name it "WWAN Off-line"
On the side-bar of network interfaces for this new location
select the interface used to talk to the broadband modem
Click on the gear at the bottom of the side-bar
and select "Make Service Inactive"
"Apply" your changes.

Now create a script that uses the scselect command (man scselect)

#!/usr/bin/env bash
/usr/sbin/scselect "WWAN Off-line"
sleep 5 # sleep for as long as you need to
/usr/sbin/scselect "What Was You Normal Location"

Since the "WWAN Off-Line" network location has disabled the interface (I assume ethernet) which talks to the broadband modem, that should break your connection.

Which you switch back to your normal network location, the interface that talks to the broadband modem should become active and re-establish a connection to your ISP.

Not sure if this will work for you, but I think you would be better getting a router. They are not expensive. They generally are WiFi base stations as well, frequently come with extra ethernet ports, some will host a printer or a shared disk drive. If cost is a factor, try searching over at <http://dealmac.com> and you should find some very cheap WiFi Routers.

Oct 24, 2010 2:37 PM in response to stairway27

My previous assumptions were that you were using Ethernet to talk to the Broadband modem. This update indicates it is a USB modem. When you create your Off-Line Location make sure you disable the correct network interface. There should be one associated with the USB modem, and that is the one you want to disable in the Off-Line location.

One thing to watch out for, is whether the switch away from your normal location to the off-line location will affect the Internet Sharing setup.

Another thing to look at is

man networksetup

which someone just pointed out in another Unix forum thread.

Message was edited by: BobHarris

Oct 24, 2010 8:50 AM in response to stairway27

Thanks for the feedback, but here's a little more information on why I'm going this route: I current have a 3g router, and it's awful.

We've been using a NetGear MBR624GU router with my AT&T Mercury (Sierra Compas 885) USB modem for about 6 months. The router cuts the bandwidth to a QUARTER of what I get when I have 3g USB modem directly connected to a Mac or PC. For example, the tests I was going last weekend averaged like this:

USB Modem Connected to Router: 1.5 Mbps Download, 0.5 Mbps Upload
USB Modem Connected to Macbook: 6+ Mbps Download, 5+ Mbps Upload

(Many have reported this is because of a bad MTU setting in the router that cannot be changed.)

I was able to share the USB Modem via Airport using Internet Sharing. I then connected my wife's Dell laptop via wireless and got the full download bandwidth (downloade new 70+ MB Java update at over 6 Mbps).

Another downfall of the router is that the USB modem disconnects about every 4 hours and does not auto-reconnect. It stays connected 4 to 6 times longer on my MacBook.

I appreciate the security concerns and subnet issues. I've got them all worked out. Here's how the sharing will work:
* USB modem connected to Mac Mini
* Mac Mini connected to wired GB Ethernet home network (Mac Mini Airport off)
* Wireless N Access point (NOT ROUTER) connected to Ethernet home network
* Mac Mini providing DHCP, NAT, and DNS via wired interface

Wireless WPA2 is handled by the Wireless N access point, and wireless clients are able to get DHCP from the Mac Mini. I've figured out how to get the Mac Mini to serve DHCP on my home IP subnet. It is not using a subnet assigned by the ISP. It all works quite well. I'm confident if I can script a twice daily down-then-up of the WWAN interface, it will be rock solid.

I'm just looking for help with the proper shell commands to bring network interfaces up and down. I've done this in Linux for years.

scselect might work, so long at it doesn't mess with a) the wired ethernet interface and b) the DHCP, NAT, and DNS services that are running via Internet Sharing. I'll give it a shot.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Shell script to bring WWAN modem down and up?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.