Most recent comments
2021 in Books -- a Miscellany
Are, 2 years, 6 months
Moldejazz 2018
Camilla, 4 years, 11 months
Romjulen 2018
Camilla, 5 years, 6 months
Liveblogg nyttårsaften 2017
Tor, 6 years, 6 months
Liveblogg nyttårsaften 2016
Are, 7 years, 6 months
Bekjempelse av skadedyr II
Camilla, 5 months, 4 weeks
Kort hår
Tor, 3 years, 6 months
Camilla, 3 years, 1 month
Melody Gardot
Camilla, 5 years
Den årlige påske-kommentaren
Tor, 5 years, 3 months
50 book challenge
Camilla, 6 months, 3 weeks
Ten years ago
Moldejazz 2014, del II
+ 2004
+ 2005
+ 2006
+ 2007
+ 2008
+ 2009
+ 2010
+ 2011
+ 2012
+ 2013
+ 2014
+ 2015
+ 2016
+ 2017
+ 2018
+ 2019
+ 2020
+ 2021
+ 2022
+ 2023

Freedom is not free

I've recently been made aware of an app called Freedom, which basicaly shuts down your Internet connection for a time. This is supposed to enhance your productivity, by keeping you from wasting time on the Internet. That's silly, I thought, why not just exercise some self control? Then I realised I don't have that much self control, so I had a look at the app. It turns out it costs $10, however, which I thought was a bit steep for something I could probably do as a one-liner in bash, so I decided to figure out how it works, or at least how I could do something similar.

At first, I thought about deactivating the network cards, which is pretty trivial from the terminal, at least on the Mac, and I guess it's the same on linux. Just type

sudo ifconfig en0 down
sudo ifconfig en1 down

to turn off both the wireless and the wired network. If you're on wired network, this works quite nicely, as most OSes don't have a convenient button to switch that card back on. With wireless network, however, it's just the same as switching off the network card in the regular way, and if that works for you, you won't be looking for a $10 app to do the job in any case. Plus, of course, you can reverse this just by typing

sudo ifconfig en0 up
sudo ifconfig en1 up

I guess a solution would be to don't have sudo on your machine, and have a friend switch the network on and off via ssh, but it's not quite as smooth.

Next, I had a look at the terminal firewall, which seems a better choice. By typing

sudo ipfw add deny ip from any to any

you add a rule to the firewall which blocks all network traffic. To go back online, you can delete all rules by typing

sudo ipfw -q flush

By the way, this command also lets you back online when using Freedom, so I assume it operates by modifying the firewall rules as well. Also, note that if you have any existing firewall rules, the last command will remove them, though I guess a reboot would reset everything to the way it was.

While ipfw seems to be the tool of choice for this job, it won't work very well if you can just switch it off with a command which is actually simpler than the one to switch it on, so I wrote a little python script which will block communication on all ports for a set amount of time. Use it by typing

sudo python 60

to block your internet access for 60 minutes, or change the number to whatever you want. The program is available here:

It works by calling ipfw to block communication as described above, then it spawns a subprocess which runs in the background and exits. The subprocess waits the prescribed amount of time, then restores communication.

At first, I thought perhaps it might be a little rude to write about this, as I guess it could potentially undermine the market for Freedom, which seems to be a one-man operation run in that one man's spare time. However I decided to go ahead anyway when I realised that the kind of people who pay $10 for an app that stops them from going online probably want a graphical interface. Also, according to the webpage, Freedom is used by hundreds of thousands of people (meaning the guy has made millons of dollars), and has been mentioned in a range of newspapers and popular webpages, including the Guardian and the New Yorker, so it seems to be doing quite well.

-Tor Nordam


Camilla,  06.01.12 11:34

I suppose I trust your code to mess with my computer under sudo settings more than I trust some random person's.

But the big question is: can you write me one of those firefox add-ons which tells you when you are heading into Facebook/Myspace places and warns you to turn back? There used to be one, but it no longer works; and I miss it.

Matteus,  09.01.12 22:49

Whatever happened to leechblock? No phone version?
Tor,  09.01.12 22:54

Leechblock stopper ikke alt det andre, som mailklienten din, MSN, twitter, etc.