tl;dr what are all the ways I can block a website on linux? Debian if it's relevant.

I want to stop myself using certain sites. Since I'm reasonably techy and can work round all blocks I've come up with, I've found an effective approach is to apply as many hurdles as possible, so that visiting the website takes effort.

So far I've added the site to ublock's block list, and redirected sites via /etc/hosts. What other options are there?

While I have admin access to the router, I'm not allowed to block sites there.

you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 3 months ago (1 child)

You can use iptables to block connections, by example, using ufw the uncomplicated firewall:

# apt install ufw bind9-dnsutils  #  Install ufw and nslookup
# uIPs=$((nslookup reddit.com && \
  nslookup www.reddit.com && \
  nslookup redd.it && \
  nslookup redditstatic.com && \
  nslookup www.redditstatic.com) \
  | awk '/^Address: / { print $2 }' | sort -u); \
for uip in ${uIPs}; do \
  echo -n "${uip} " &&  \
  ufw deny from "${uip}" comment 'deny reddit.com'; \
  ufw deny out to "${uip}" from any comment 'deny reddit.com'; \
done;
# ufw enable
# ufw status numbered
  • source
  • hideshow 1 child comment
  • [–] 1 point 3 months ago* (last edited 3 months ago)

    Also, to block them in the firefox browser, you can also use the FoxyProxy extension, and use the proxy by patterns options to use a non-existant proxy for the domains that you want to block.

    Edit to add config example:

  • source
  • parent