If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Why is 127.0.0.1 used for hosts file redirects instead of 127.0.0.0?
You can obtain pre-compiled hosts files used to block ad sources, phish
sites, malicious sites, or other content (based on an IP name that has to include the hostname in the URL since this is, after all, a *hosts* file). One such pre-compiled hosts file is the one from the MVPs site (http://www.mvps.org/winhelp2002/hosts.htm). However, I'm wondering why the loopback address of 127.0.0.1 (for localhost) was chosen. 127.0.0.1 actually exists since it is the loopback interface defined in your NIC. If you put http://127.0.0.1/ into your web browser, you see it cogitate a couple seconds before erroring. 127.0.0.0 is the default network. Putting http://127.0.0.0/ results in an immediate failure. The web server won't try to connect to a particular host. The idea of using 127.0.0.1 only works if you are NOT running your own web server. If you are then obviously the hosts file that redirects to 127.0.0.1 is trying to connect to your own web server when the intent was to block a connection to the content at the specified host in the URL. This means you could see content from your own web site intermingled with the web page (where you were attempting to block some content or that site using the hosts file). Well, obviously it will take some time to retrieve web pages from your own server. Any local process listening on port 80 would connect to the 127.0.0.1 address you use in the hosts file for redirection (in trying to block content). So why even bother trying to use the loopback IP address? What happens if you have a web server that is local and listening on port 80 (for the HTTP connects)? Why waste time trying to connect to your local web server, if you have one or to even try to connect to one, if the point is to block content? Why not use 127.0.0.0 which results in an instant failure and would never connect to your web server should you ever decide to run one? Or use 127.0.0.254 which is unlikely ever to get used in your internal network path to define a host (but even that takes longer to generate an error than using 127.0.0.0)? Why the focus on using 127.0.0.1 to block content using the hosts file? Why would you want your web browser to even try to find localhost when the point is to always fail in order to block that content? |
Ads |
Thread Tools | |
Display Modes | |
|
|