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.

    • moonpiedumplings@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      7 days ago

      lmao. I hate takes like this.

      It’s not about making the website impossible to get to, it’s about making the website more difficult and annoying to get to than an alternative productive activity/site.

      Part of making it difficult to get to is technical.

  • communism@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    15 days ago

    Maybe block on your router and save your router password such that you need to jump through several hoops to unlock it, eg password saved in one password manager DB whose master password is in another DB whose password is in another DB, etc. If you have to unlock like 10 password databases to get into your router, you’ll probably give up on whatever bad habit you were trying to do as it’s too much effort.

  • FoundFootFootage78@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    ·
    15 days ago

    DNS level blocking is a massive pain to circumvent. Adguard DNS and NextDNS allow you to do this. Mullvad DNS allows you to block adult websites, gambling sites, and (optionally) social media without creating an account.

  • barlog@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    15 days ago

    I use NextDNS and it has feature to block domains. Unfortunately i often unblock it back.

  • D_Air1@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    16 days ago

    Any of the adblockers can do this. Pihole, adguard home, technitium. Ublock origin to. You can probably do it pretty painstakingly through the hosts file as well.

  • Mensh123@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    14 days ago

    LeechBlock NG isn’t exactly what your’e looking for but it still may help. Of course, it’ll have no effect if UBO and the DNS already shut everything off.

  • Novi Sad@feddit.org
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    16 days ago

    Roughly from high level to low level:

    1. uBlock custom filters
    2. Make pages unusable or less attractive by wonky per-site browser or extension settings
    3. IP and DNS blocks on your local machine
    4. Run a DNS proxy on your local machine and block domains with it
    5. Host a pihole server on a different machine, make it your DNS server and block domains there
    6. IP and DNS blocks in your router (if your current one has no option for this, consider buying another, preferably used)

    Best apply the methods arbitrarily, so that you get even more confused about how you might restore access to a given website.

    Options 5 and 6 may be the only viable ones for locking down certain smartphones or tablets.

  • Levi@lemmy.ca
    link
    fedilink
    English
    arrow-up
    1
    ·
    16 days ago

    If redirecting with /etc/hosts isn’t enough, you could set up a cron job (I guess as root?) to re-copy a hosts file back to /etc/hosts every half hour or something. That way even if you do manually change /etc/hosts for an quick peak of an illicit website, it’ll go back to being blocked in a short amount of time. This’ll add a bit of the “pain in the ass” factor.

  • dieTasse@feddit.org
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    14 days ago

    You could try behavioral therapy. Doesn’t need to be psychiatrist (but does have to be professional).

  • redrum@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    15 days ago

    You can also use a firewall to deny/reject outgoing and incoming traffic to those IPs. By example, with ufw:

    # apt install ufw bind9-dnsutils  # install Uncomplicated Firewall and dig
    # ufw enable  # activate the firewall
    # dig +short reddit.com  # get reddit A IPs
    151.101.65.140
    151.101.1.140
    151.101.193.140
    151.101.129.140
    # ufw deny in on all from 151.101.65.140 comment 'deny in connections to reddit'
    # ufw deny out on all to 151.101.65.140 comment 'deny out connections to reddit'
    . . . 
    

    Or in only one line:

    uIPs=$(dig +short reddit.com); for uip in "${uIPs}"; do echo "$uip"; done;
    
    
  • redrum@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    14 days ago

    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
    
    • redrum@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      14 days 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:

  • jdnewmil@lemmy.ca
    link
    fedilink
    arrow-up
    2
    arrow-down
    2
    ·
    15 days ago

    See a psychiatrist. You already have root on these systems… if you are truly a split personality then fences aren’t going to prevent your other self from doing whatever they want.