this post was submitted on 12 Jun 2026
18 points (100.0% liked)

Linux

65722 readers
525 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
18
How can I block websites? (programming.dev)
submitted 9 hours ago* (last edited 9 hours ago) by staircase@programming.dev to c/linux@lemmy.ml
 

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.

top 16 comments
sorted by: hot top controversial new old
[–] Cyber@feddit.uk 2 points 2 hours 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.

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

[–] undefinedTruth@lemmy.zip 1 points 3 hours 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.

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

[–] BartyDeCanter@piefed.social 13 points 8 hours ago

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.

[–] whatiswrongwithyou@lemmy.ml 10 points 7 hours 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 6 points 7 hours ago

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

[–] kungen@feddit.nu 14 points 8 hours ago

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.

[–] Delilah@lemmy.blahaj.zone 6 points 7 hours ago

Therapy is probably a better option.

[–] anamethatisnt@sopuli.xyz 5 points 8 hours 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 5 points 8 hours ago

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.

[–] Fleppensteijn@sh.itjust.works 1 points 6 hours ago

Can you use another device? Write a script that accesses your computer though ssh, check the hosts file and run rm -rf or something when it isn't there

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

[–] Holytimes@sh.itjust.works 2 points 9 hours 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 8 hours ago (1 children)

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

[–] SocialistVibes01@lemmy.ml 3 points 4 hours ago

lol it's probably porn