Newbie here.
What I am trying to do:
I am trying to make certain sites unreachable from my computer (just blacklist those domains). I was also considering making them unreachable at certain times of the day, but making them unreachable in the first place isn't even working with what I found and tried. I don't want to use addons or extensions for browsers as all I've looked at note that they will access to all my data, and I don't like that. I would like to resolve this through iptables if possible but if not I am open to other approaches, but its just that Ive devoted too much of my time to this approach already.
What I've done first:
Firstly, I've searched this forum and looked and tried the proposed solutions on several pages of posts about the topic (as well in "Click here to find similar threads button") and could not find anything that gave me a solution to my problem (opened sites and youtube links about this to check those as well) - for some reason unknown to me, the proposed solutions wouldn't work for me, so apologies if I missed some solution already given. :/
My setup:
My system is Debian GNU/Linux 10 (buster). My computer doesn't have wireless capability but is connected to the router over an Ethernet cable and that works fine. I am not connected through some VPN or something (not that I know of). I've used “ip link show” command in terminal to show me the MAC address of my system:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether <shows me my MAC address here; omitted by me> brd ff:ff:ff:ff:ff:ff
What I've tried:
First, I've created a iptables list:
sudo iptables -N bslist
I've tried to create a blocking of a site from my system using the following command (didn't work):
sudo iptables -I bslist -p tcp -m mac --mac-source <my MAC address here; omitted by me> -m string --string "https://www.reddit.com/" --algo kmp -j REJECT
Note: For each following step all the previous iptables entries done by me were replaced or deleted so they could not interfere.
I've also tried it sans the MAC address(also didn't work):
sudo iptables -R bslist 1 -p tcp -m string --string "https://www.reddit.com/" --algo kmp -j REJECT
I've also tried to edit the hosts file to redirect it to 127.0.0.1 (also didn't work):
sudo nano /etc/hosts
127.0.0.1
https://www.reddit.com/
I've also tried a variant of this without the
https://www
127.0.0.1 reddit.com
still didn't work
Finally I tried:
sudo iptables -I bslist -s
www.reddit.com -j DROP
Would anyone kindly help me find a solution for this? Thank you.
P.S. If someone could help me on how to set rules for blocking the sites at certain times of the day, that would be a great bonus, but I would be just as satisfied with knowing how to block a website in the first place.