this post was submitted on 12 Jun 2026
27 points (93.5% liked)

Linux

65746 readers
1056 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS
 

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.

all 36 comments
sorted by: hot top controversial new old
[–] Mensh123@lemmy.world 1 points 3 hours 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.

[–] racketlauncher831@lemmy.ml 2 points 6 hours ago (1 children)

Don't look for a solution that is technical where the problem is mental.

[–] placebo@lemmy.zip 1 points 5 hours ago

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.

[–] barlog@lemmy.ml 1 points 5 hours ago

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

[–] exaybachae@startrek.website 1 points 6 hours ago

Private DNS service.

[–] Tenderizer78@lemmy.ml 2 points 9 hours 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.

[–] communism@lemmy.ml 3 points 12 hours 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.

[–] jdnewmil@lemmy.ca 0 points 9 hours 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.

[–] tarzst@sh.itjust.works 4 points 23 hours ago

/etc/hosts and set the websites to go to 0.0.0.0 or 127.0.0.1

[–] staircase@programming.dev 1 points 20 hours ago

thanks all, these are good suggestions

[–] MonkderVierte@lemmy.zip 3 points 1 day ago
[–] kungen@feddit.nu 19 points 1 day ago (2 children)

Therapy of some sorts is probably going to be more effective than making self-blocks, especially if you're technically competent. I wish you luck with stopping whatever addiction it is.

[–] aksdb@lemmy.world 2 points 15 hours ago

It can help. A lot of the time I go on Reddit for example starts subconscious. If that doesn’t work the conscious part kicks in and I know I don’t want to visit that craphole so I close the tab again and put the phone aside. Otherwise I see content and keep scrolling.

[–] Wolf314159@startrek.website 3 points 21 hours ago

The real hack is (almost) always social.

[–] BartyDeCanter@piefed.social 16 points 1 day ago (2 children)

Setup a PiHole and add them to the blocklist. Then make the PiHole password stupid long and write it down. Then take the paper, put it in a safe, and put it in the highest shelf in the back of your closet. Recurse safes and passwords as much as needed.

[–] Tenderizer78@lemmy.ml 1 points 9 hours ago

You could just change your DNS server to get around that though, even without the password.

[–] nyan@sh.itjust.works 3 points 22 hours ago (2 children)

Even better, store the password offsite—safe at a friend's house, safety deposit box at the bank . . .

[–] BartyDeCanter@piefed.social 3 points 20 hours ago* (last edited 20 hours ago)

And if you don’t have any friends or a bank, put it in a double ziplock, then drop it in a Tupperware of water and freeze it.

[–] staircase@programming.dev 1 points 20 hours ago

well I do hate going into town, so that would work

[–] whatiswrongwithyou@lemmy.ml 15 points 1 day ago (1 children)

You’re gonna have better luck changing your habits than you will making a block that you yourself can’t overcome.

[–] tofu@lemmy.nocturnal.garden 13 points 1 day ago

Creating hurdles can help lowering the temptation. I totally get OP.

[–] Cyber@feddit.uk 3 points 1 day ago

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.

[–] Delilah@lemmy.blahaj.zone 5 points 1 day ago

Therapy is probably a better option.

[–] Novocirab@feddit.org 4 points 1 day ago* (last edited 1 day 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.

[–] anamethatisnt@sopuli.xyz 4 points 1 day ago (1 children)

Only thing I can think of is to remove your default account from the sudoers file and have an account with a frustratingly long password written on physical paper hold the keys to the kingdom. That will make a whole lot of other things a hurdle too though.

[–] Peffse@lemmy.world 4 points 1 day ago (1 children)

Yeah, whatever roadblocks are set up can easily be dismantled using the same privs.

Only way to achieve this goal is to either hand the keys to someone else or to lock yourself out.

[–] Scrath@lemmy.dbzer0.com 1 points 2 hours ago* (last edited 2 hours ago)

Making it a hassle to circumvent the roadblocks can help make the undesired behavior less attractive to you in the moment or stop unconscious behavior.

For example, I sometimes open lemmy just with my muscle memory when I'm bored without even thinking about it, even though I know I've scrolled through pretty much all the current content I get in my feed already.

Moving the app icon around stops me from opening lemmy without actively thinking about it and therefore adds a (admittedly small) barrier to my bad behavior.

Adding a long and complex password that I would have to enter manually, as someone in the comments recommend, would probably make me rethink my actions even more. Do I really want to get out the password and be annoyed by having to type it out just to do this?

[–] D_Air1@lemmy.ml 2 points 1 day 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.

[–] Levi@lemmy.ca 2 points 1 day 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.

[–] undefinedTruth@lemmy.zip 1 points 1 day ago

NextDNS is a good option for your use case. It allows you to block entire categories of websites and even has an option to setup a schedule on when you are allowed to access them. It also has blocklists you can pick from and the ability to blacklist and whitelist individual domains. And the free plan is very generous. You can just try it and see how it works for you.

[–] Holytimes@sh.itjust.works 2 points 1 day ago

Just set the site to be hidden? If it's not in the list you didn't even know its an option and thus everything else is moot.

Pretty sure every search engine at thing point has a option to just "not show results from this website" or equivalent.

Out of sight out of mind.

[–] rain_worl@lemmy.world 1 points 1 day ago (2 children)

i'm curious what websites are you doing. what's the threat model??

[–] staircase@programming.dev 2 points 1 day ago* (last edited 1 day ago)

reddit; may add news sites given the wonderful news we're getting these days

[–] SocialistVibes01@lemmy.ml 2 points 1 day ago

lol it's probably porn