| 1. |
Solve : Hosts file Help? |
|
Answer» I did not know where to postt this, but I will post it here.... I want to know if it's possible to create some sort of file(batch or whatever) that can configure the hosts file in a certain way when you open it. Like a file that blocks a certian site when you run it, and then another one which allows the site again, when you run IT... Wow Mr. Google, Wise words from Khasiar. This boy will GO far i hope soAlso I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious. So. The Hosts file in Windows is a text file. Each line contains an IP address and a host name, in that order, separated by at least one space. Example: Code: [Select]212.140.189.10 www.tesco.com When a request to connect to a host name is made by a program for example a WEB browser, or any other other program, the system looks first in the Hosts file and if the host name is found, the IP address on that line is used. If it is not found, then a DNS lookup is performed. If it is desired to block a particular site, then that host name can be given the IP address of LOCALHOST, the local computer, which is always 127.0.0.1 Code: [Select]127.0.0.1 www.blocked-site.com Now any attempt to read www.blocked-site.com will result in an error page. There is the possibility that malicious editing of the Hosts file could redirect traffic from a desired site to another one. This is why many security applications protect the Hosts file and monitor attempts to alter it. Quote from: Dias de verano on August 03, 2008, 02:49:53 AM Also I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious. I thought it was 0.0.0.0 that's what I use. I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code a try: Code: [Select]echo off echo 0.0.0.0 www.facebook.com >> hosts exit I have a feeling this isn't quite there yet. Quote from: Mr. Google on August 03, 2008, 09:09:30 AM
127.0.0.1 is the local machine, and using it as a block address in the Hosts file is the normal way. 0.0.0.0 is a "nil host" address and works just as well. Quote I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code a try: It adds a host to be blocked, but how to remove it? something like this maybe Remove a host from hosts file syntax batchfile hostname e.g. call it unblock.bat & use it thus: unblock www.hostname.com Code: [Select]echo off cd /d c:\windows\system32\drivers\etc if exist hosts2 del hosts2 type hosts | find /v /i "%1" > hosts2 copy /y hosts2 hosts I'm not quite sure if I understand that... Quote from: Mr. Google on August 04, 2008, 09:00:41 AM I'm not quite sure if I understand that... I was afraid of that. If you do not understand that code, you should not be poking around in system folders. Quote from: Dias de verano on August 04, 2008, 11:04:38 AM Quote from: Mr. Google on August 04, 2008, 09:00:41 AMI'm not quite sure if I understand that... *ignore comment* |
|