1

I'm trying to block site with configuring /etc/hosts file.

sudo sh -c 'echo "0.0.0.0 http://youtube.com" >> /etc/hosts'

but I still can access youtube from browser(s). even I changed the domain to 127.0.0.1 but it didn't work.

1

3 Answers 3

5

/etc/hosts only deals with the hostname you are accessing, not the whole web address. So to block http://youtube.com/..., you only want to specify youtube.com because that is the host.

Note that YouTube actually uses www.youtube.com (with the www) and that is considered a different hostname so you'd have to block that too.

The final thing to note is that this just blocks your ability for your DNS system to be able to look up YouTube by its hostname. It is not securely blocking YouTube, as users may be able to look up its IP addresses some other way. A determined user could do it.

1

Try sudo sh -c 'echo "0.0.0.0 youtube.com" >> /etc/hosts'

0

just type www.youtube.com in the /etc/hosts file

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .