How do you block gmail through etc/hosts?
May 16, 2013 2:46 AM Subscribe
Most "distracting" sites I can block by an entry in my etc/hosts file (Mac OSX 10.8.2). e.g.:
127.0.0.1 plus.google.com
But this method doesn't seem to be able to block gmail.
Here's the relevent lines in my etc/hosts file:
127.0.0.1 localhost
255.255.255.255 broadcastlocalhost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 https://gmail.com
127.0.0.1 gmail.com
127.0.0.1 www.gmail.com
127.0.0.1 https://mail.google.com
127.0.0.1 mail.google.com
127.0.0.1 https://accounts.google.com
127.0.0.1 accounts.google.com
But none of these seem to block gmail.
Does anyone have any suggestions?
I could try a "site blocker" but most of these rely on setting a "blocking time" e.g. 30 minutes -- this is not practical for gmail as I want to be able to log into it when I need to confirm my email address if I sign up to a site. I would prefer to be able to block gmail with the knowledge that I could unblock it in about 30s -- I find this "overhead" gives the best of both worlds.
I could also take Ritalin, and/or practice my self-control. That's also another option :).
NB: moments before I was about click "post" I was able to solve this. I'll post the solution then close the question in the hope it helps someone else.
Here's the relevent lines in my etc/hosts file:
127.0.0.1 localhost
255.255.255.255 broadcastlocalhost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 https://gmail.com
127.0.0.1 gmail.com
127.0.0.1 www.gmail.com
127.0.0.1 https://mail.google.com
127.0.0.1 mail.google.com
127.0.0.1 https://accounts.google.com
127.0.0.1 accounts.google.com
But none of these seem to block gmail.
Does anyone have any suggestions?
I could try a "site blocker" but most of these rely on setting a "blocking time" e.g. 30 minutes -- this is not practical for gmail as I want to be able to log into it when I need to confirm my email address if I sign up to a site. I would prefer to be able to block gmail with the knowledge that I could unblock it in about 30s -- I find this "overhead" gives the best of both worlds.
I could also take Ritalin, and/or practice my self-control. That's also another option :).
NB: moments before I was about click "post" I was able to solve this. I'll post the solution then close the question in the hope it helps someone else.
127.0.0.1 https://gmail.com
127.0.0.1 https://mail.google.com
127.0.0.1 https://accounts.google.com
I don't think URLs are valid entries in /etc/hosts. If I recall, it's just for mapping hostnames to IP addresses.
posted by RonButNotStupid at 4:43 AM on May 16, 2013 [3 favorites]
127.0.0.1 https://mail.google.com
127.0.0.1 https://accounts.google.com
I don't think URLs are valid entries in /etc/hosts. If I recall, it's just for mapping hostnames to IP addresses.
posted by RonButNotStupid at 4:43 AM on May 16, 2013 [3 favorites]
Yeah - /etc/hosts is only IPs and hostnames. The URL entries are not going to do a whole lot and you can safely delete them.
posted by jquinby at 5:13 AM on May 16, 2013 [1 favorite]
posted by jquinby at 5:13 AM on May 16, 2013 [1 favorite]
I use LeechBlock on Firefox, it does not require that you set a time for sites, you can have it turned on and block sites always, and turning it off when needed is pretty quick for me.
posted by effigy at 6:52 AM on May 16, 2013
posted by effigy at 6:52 AM on May 16, 2013
You can flush the DNS cache and avoid the rebooting.
If you want some finer grained control check if the `dnsmasq` application is available on Mac OS. It is a local DNS server thing... you configure your system to use dnsmasq as its DNS server, then configure dnsmasq to use your real DNS server. Then you can configure dnsmasq to return 127.0.0.1 for wildcards like '*.google.com' and do real lookups for specific 'app.google.com'. A bit more power, but a bit more headache than editing the hosts file.
posted by zengargoyle at 11:39 AM on May 16, 2013 [1 favorite]
dscacheutil -flushcache
There's a layer between the hosts file or DNS server queries and applications where successful lookups are cached for a while to improve performance. They may also be cached in the application itself requiring an application restart to pick up changes.If you want some finer grained control check if the `dnsmasq` application is available on Mac OS. It is a local DNS server thing... you configure your system to use dnsmasq as its DNS server, then configure dnsmasq to use your real DNS server. Then you can configure dnsmasq to return 127.0.0.1 for wildcards like '*.google.com' and do real lookups for specific 'app.google.com'. A bit more power, but a bit more headache than editing the hosts file.
posted by zengargoyle at 11:39 AM on May 16, 2013 [1 favorite]
« Older Too good to leave, too bad to stay - therapist... | Can a Person Practice Dianetics and Not be a... Newer »
This thread is closed to new comments.
http://superuser.com/questions/544789/why-cant-i-block-facebook-using-etc-hosts-on-mountain-lion
In that you needed something like this:
fe80::1%lo0 gmail.com
But what solved it was restarting the computer.
posted by tomargue at 2:53 AM on May 16, 2013 [1 favorite]