Many of us use /etc/hosts as a productivity tool: we block certain highly addictive websites (Facebook, Twitter, Hacker News, Reddit etc.) so that we can't access them from our own workstation without going to the pain of re-editing the file. Yesterday, I noticed that I could access Facebook despite having routed 13 unique Facebook URLs to localhost in my /etc/hosts file. What was going on? The answer was IPv6. I had routed the Facebook addresses to 127.0.0.1, which of course is an IPv4 address. However, now that IPv6 is live, those URLs could bypass my IPv4 block and route to the newer IPv6 addresses. ::1 is the feedback loop for IPv6, so I needed to add it to /etc/hosts to keep Facebook blocked.
In short, we now need to include both IPv4 and IPv6 addresses when using /etc/hosts to block sites.
Here is the Facebook section of my /etc/hosts file now:
# Block Facebook IPv4 127.0.0.1 www.facebook.com 127.0.0.1 facebook.com 127.0.0.1 login.facebook.com 127.0.0.1 www.login.facebook.com 127.0.0.1 fbcdn.net 127.0.0.1 www.fbcdn.net 127.0.0.1 fbcdn.com 127.0.0.1 www.fbcdn.com 127.0.0.1 static.ak.fbcdn.net 127.0.0.1 static.ak.connect.facebook.com 127.0.0.1 connect.facebook.net 127.0.0.1 www.connect.facebook.net 127.0.0.1 apps.facebook.com # Facebook IPv6 ::1 www.facebook.com ::1 facebook.com ::1 login.facebook.com ::1 www.login.facebook.com ::1 fbcdn.net ::1 www.fbcdn.net ::1 fbcdn.com ::1 www.fbcdn.com ::1 static.ak.fbcdn.net ::1 static.ak.connect.facebook.com ::1 connect.facebook.net ::1 www.connect.facebook.net ::1 apps.facebook.com