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.
/etc/hosts and set the websites to go to 0.0.0.0 or 127.0.0.1
use the redirector addon to auto redirect somewhere else
You could try behavioral therapy. Doesn’t need to be psychiatrist (but does have to be professional).
Don’t look for a solution that is technical where the problem is mental.
It’s not a solution to a problem, it’s a mitigation option. There is a lot of evidence that it works. Even OP mentioned that it’s effective for them.
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.
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.
I use NextDNS and it has feature to block domains. Unfortunately i often unblock it back.
Private DNS service.
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.
DNS… set your system up to use an external DNS provider like OpenDNS where you can select categories to block.
I used this to block adult, gambling, malware, etc at the grandparent’s house when the kids were growing up and starting to search the internet for school homework, etc.
If it’s done in the router you’ll cover all devices and you give someone else the password, so you can’t change it.
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.
You can use iptables to block connections, by example, using
ufwthe 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 numberedAlso, to block them in the firefox browser, you can also use the
FoxyProxyextension, 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:

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;thanks all, these are good suggestions








