2

In order to block some certain sites, I use the following codes in my hosts file:

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
127.0.0.1 http://www.hamdardi.net/  

But that works only when I'm not connected to a VPN.
How can I block a certain website using hosts file even if I'm connected to a VPN?
please avoid suggestions like leechblock for firefox, stayfocused for google chrome. I want a solution that works for all browsers installed on my computer (IE, firefox, google chrome) that doesn't let me to access and edit the blocking settings while the sites are blocked.
I have tried a lot of ways like localfilter, BinarySwitch Eclipse, etc. But I've always found a way to sneak out.
This time I wanna block the sites using hosts file and then set a random password on the file for the administrator of the computer (not the SYSTEM) and give this password to someone else

3

Hosts file should always work - VPN or not. Drop the http protocol. These entries should be sufficient:

127.0.0.1 www.hamdardi.net

127.0.0.1 hamdardi.net

Edit: Useful debugging guide: https://serverfault.com/a/452269

9
  • Marek Rost is right. Your mistake is that you have written "http://www.hamdardi.net/". HOSTS file only accepts fully qualified domain names, not URLs. – user477799 Jul 30 '16 at 14:35
  • @FleetCommand but the solution didn't work. I've shared my hosts file content here for you – Sepideh Abadpour Jul 30 '16 at 15:02
  • @sepideh as FleetCommander said only FQDNs = fully qualified domain names can be used. You have several errors in the file. As a result your entries are completly ignored. No ports or mapping ip address to ip address is allowed. Same with wildcards, so this line won't work as well: 127.0.0.1 CRL.VERISIGN.NET.* – Marek Rost Jul 30 '16 at 15:04
  • 2
    @sepideh hopefully this will help you: nopaste.me/view/49d8ffa7 – Marek Rost Jul 30 '16 at 15:22
  • 1
    From what i found: it varies case to case - sometimes, when there is error in syntax, it is ignored completly. Another time rules are applied from start of file until the first mistake. This is why i posted that debuggin link into the answer - so you can test it out and see if changes in the file were applied. – Marek Rost Jul 30 '16 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.