LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Trying blockwebsites in Linux.. (https://www.linuxquestions.org/questions/linux-general-1/trying-blockwebsites-in-linux-4175703838/)

Metaphycisian 11-19-2021 07:18 PM

Trying blockwebsites in Linux..
 
Steps to block websites in Linux
Open terminal shortcut keys Ctrl + Alt + T.
Type sudo gedit /etc/hosts and type Ubuntu password.
Then at the bottom of file. Type each website’s name you want to block like this:
127.0.0.1 www.facebook.com
127.0.0.1 www.youtube.com

Blocking websites has gone well but now blocking websites through this doesn't work anymore.. I don't know why.. I tried to block 127.0.0.1 www.lichess.org and it didn't block it..

Terminal just stated

(gedit:6059) warning: 03:11:57.960: Set document metadata failed: Setting attribute metadata: gedit- encoding not supported.

This blocking way doesn't work anymore.. It doesn't block anymore.

jefro 11-19-2021 08:40 PM

There is a lot to this question.

One is how a FQDN can be looked up. Might use dig to see what is being returned. Also in that is ipv6 lookup. The order of lookup used to be almost always hosts file first but can be changed to different orders.

Cache can be causing.

Any number of variations on the URL might need to be edited to hosts or wild cards used like
0.0.0.0 *.ru

Last part is what seems to be the way you are trying to edit the file. Might use vim instead.

Turbocapitalist 11-19-2021 09:07 PM

You might also find it more useful to route through Squid and / or block using NFTables. As far as trackers go, there is a lot more to either the two examples than the single domain.

ondoho 11-20-2021 01:51 AM

Quote:

Originally Posted by Metaphycisian (Post 6302853)
Terminal just stated

(gedit:6059) warning: 03:11:57.960: Set document metadata failed: Setting attribute metadata: gedit- encoding not supported.

Please open a terminal, become root ('sudo -i'), and show us:
Code:

file /etc/hosts
ls -l /etc/hosts
cat /etc/hosts

Next tine you might want to use nano instead of gedit.

Turbocapitalist 11-20-2021 02:12 AM

Quote:

Originally Posted by ondoho (Post 6302909)
Next tine you might want to use nano instead of gedit.

Or use sudoedit launch it. That way you can still edit the /etc/hosts file as root but gedit only runs as the regular, unprivileged account.

lvm_ 11-20-2021 04:55 AM

You are not blocking network traffic to websites, you are only blocking DNS resolution, and modern browsers tend to use secure DNS which is impervious to this type of blocking e.g. in firefox - 'enable DNS over HTTPS' in network settings.

lleb 11-22-2021 10:00 AM

another easy option is to look into Pi-Hole. You can run it as a VM, local, or on the RPi. This is a full DNS local resolver and you can block domains with or without wildcards.

Metaphycisian 12-06-2021 12:12 PM

Linux Hebrews
 
jefro,turbocapitalist and ondoho, it's hard for me to follow your advice because can you give more simple advices like just simple step by step advices for total linux beginner. It's hard to follow that linux programming language.. I don't understand those texts..

TB0ne 12-06-2021 12:15 PM

Quote:

Originally Posted by Metaphycisian (Post 6307137)
jefro,turbocapitalist and ondoho, it's hard for me to follow your advice because can you give more simple advices like just simple step by step advices for total linux beginner. It's hard to follow that linux programming language.. I don't understand those texts..

No one has posted any 'programming language', and if you don't understand those answers, have you tried looking them up for further explanation?? What you're asking is complicated and requires different programs and setup. This isn't a simple task.

Turbocapitalist 12-06-2021 12:16 PM

Sure:

Code:

export EDITOR=geany
sudoedit /etc/hosts

Or

Code:

export EDITOR=nano
sudoedit /etc/hosts

That will use the designate editor but won't run it as root.

djk44883 12-06-2021 02:23 PM

Doesn't all of the only work as long as your browser and/or devices are NOT allowed to use DoH - DNS over HTTPS or DoT - DNS over TLS?

Modern or current version browses may default to an external secure DNS. If it's not using port 53 and/or local DNS, will any of this solve an issue?

https://support.mozilla.org/en-US/kb...dns-over-https

https://blog.chromium.org/2020/05/a-...wsing-DoH.html

jefro 12-06-2021 02:43 PM

https://www.currentware.com/dns-over...ur-web-filter/

ondoho 12-07-2021 12:50 PM

Quote:

Originally Posted by Metaphycisian (Post 6307137)
jefro,turbocapitalist and ondoho, it's hard for me to follow your advice because can you give more simple advices like just simple step by step advices for total linux beginner. It's hard to follow that linux programming language.. I don't understand those texts..

First of all you're going to have to open a terminal window where you type in these commands suggested by us at the prompt.

Metaphycisian 12-08-2021 01:35 AM

Ondoho:

file /etc/hosts
ls -l /etc/hosts
cat /etc/hosts

When i tried to wrote those in the terminal. Nothing happened..

Jefro:

One is how a FQDN can be looked up. Might use dig to see what is being returned. Also in that is ipv6 lookup. The order of lookup used to be almost always hosts file first but can be changed to different orders.

Cache can be causing.

Any number of variations on the URL might need to be edited to hosts or wild cards used like
0.0.0.0 *.ru

How i look FQDN in my computer and what is even FQDN? Okay, how do i look ipv6 and what is ip6b?? What is cache and and how do i handle cache??? So can i block websites just writing 0.0.0.0 and then websites in the hosts??



Turbocapitalist:

What is Squid and how can i use Squick to block websites??? Where do i find squid from my computer??


LVM: You are not blocking network traffic to websites, you are only blocking DNS resolution, and modern browsers tend to use secure DNS which is impervious to this type of blocking e.g. in firefox - 'enable DNS over HTTPS' in network settings.

What is DNS resolutions? How do i block then these websites if that doesn't work??

Ileb:

another easy option is to look into Pi-Hole. You can run it as a VM, local, or on the RPi. This is a full DNS local resolver and you can block domains with or without wildcards.

So what is Pi- Hole? How do i look Pi-Hole? Does it happen through terminal or what? What commands i should use it order to look it??? What is VM,Local and the RPi?? I don't understand those words.. How do i even run those??? What is DNS Local resolver ???

Turbocapitalist:

export EDITOR=geany
sudoedit /etc/hosts
Or

Code:
export EDITOR=nano
sudoedit /etc/hosts

I was writing those in my terminal but nothing happened...

DJK:I have only google chrome in my computer not mozilla..

Ondoho: I tried to type those commands in terminal and nothing happened..

pan64 12-08-2021 02:46 AM

pihole has its own website. https://pi-hole.net/


All times are GMT -5. The time now is 10:58 PM.