How can I prevent an application (Dropbox) from accessing network when connected to a certain Wifi ESSID?

3

2

I sometimes connect my Ubuntu laptop to my phone's 3G connection via tethering. When connected to that network I don't want Dropbox to synchronize as I have a limited data plan. I do want it synchronize when connected to my work or home Wifi.

I am looking for a clean yet easy solution in linux and more specifically Ubuntu. A more sophisticated solution that would actually place caps on the bandwidth for Dropbox when connected to certain wifi ESSIDs is also desirable.

smichak

Posted 2012-08-08T03:46:33.953

Reputation: 133

1Here's a possible start. Dropbox uses port 443 (SSL). You won't want to block this port. So blocking the destination is an option. Here are the destination IP's 199.47.216.0/22 108.160.160.0/20 205.189.0.0/24 What you want to do is create a script that when SSID = X, or when my public IP = aaa.bbb.ccc.ddd, block the following IP's. At least that's the idea I have for the moment. – Everett – 2012-08-08T03:52:50.080

1I don't want to use static IP addresses. I was thinking more about a solution that would recognize the Dropbox daemon instead of the target of the communication. – smichak – 2012-08-08T04:00:34.847

1You're not using static IP's, you are blocking the connection to DropBoxes IP's. It's the only way that you would be able to throttle traffic FYI (throttle instead of block). However, it sounds like you want a script that says when SSID = X, kill Dropbox Daemon. – Everett – 2012-08-08T04:03:46.853

Answers

9

Instead of blocking dropbox, you could simply stop it when you are connected to the network in question (you don't need dropbox running to access locally synchronised files)

For example, placing the following in /etc/network/if-up.d/ will make it run after a network connection is established:

#!/bin/bash
ifconfig -a | grep -q "192\.168\.0\." && killall dropboxd

This will kill (gracefully) the dropbox daemon when you connect to a network that give you an ip address in the 192.168.0.* range. If you can determine something that will identify your 3G network after connecting, then you can simply stop dropbox when you connect. You could extend this script to start dropbox when connecting to other networks.

Paul

Posted 2012-08-08T03:46:33.953

Reputation: 52 173

Good going Paul! +1 – Everett – 2012-08-08T04:15:45.950