FlyerTalk Forums

FlyerTalk Forums (https://www.flyertalk.com/forum/index.php)
-   Travel Technology (https://www.flyertalk.com/forum/travel-technology-169/)
-   -   Question on using the hosts file (https://www.flyertalk.com/forum/travel-technology/1658561-question-using-hosts-file.html)

BigLar Feb 27, 2015 10:32 am

Question on using the hosts file
 
Just resurrected an older laptop and testing it out. I noticed that one particular site was downloading a bunch of ad-related stuff, and I thought, "Of course! I never put in the hosts file."

I couldn't find the one I had been using (~650K) so I googled around and found one from Malwarebytes. I figured these guys ought to know what they're doing, so I downloaded it and installed it. 30 megs. Are you kidding?

Anyhow, I picked an entry at random (let's call it www.dumbsite.com) and put that address in the browser. What I expected to happen was nothing - it would find the entry in the hosts file, try to connect to myself (127.0.0.1) and that would be it. Instead, it went to the site.

So ... I'm probably misunderstanding how this stuff works (nothing new here, folks).

1. Does it matter which browser I use (IE, Chrome, Opera)?

2. Is that how it really works? It first checks the hosts file, then the internal dns cache and then sends out to the ISP's DNS server. If not, what's going on here?

Dodge DeBoulet Feb 27, 2015 12:12 pm


Originally Posted by BigLar (Post 24425376)
Just resurrected an older laptop and testing it out. I noticed that one particular site was downloading a bunch of ad-related stuff, and I thought, "Of course! I never put in the hosts file."

I couldn't find the one I had been using (~650K) so I googled around and found one from Malwarebytes. I figured these guys ought to know what they're doing, so I downloaded it and installed it. 30 megs. Are you kidding?

Anyhow, I picked an entry at random (let's call it www.dumbsite.com) and put that address in the browser. What I expected to happen was nothing - it would find the entry in the hosts file, try to connect to myself (127.0.0.1) and that would be it. Instead, it went to the site.

So ... I'm probably misunderstanding how this stuff works (nothing new here, folks).

1. Does it matter which browser I use (IE, Chrome, Opera)?

2. Is that how it really works? It first checks the hosts file, then the internal dns cache and then sends out to the ISP's DNS server. If not, what's going on here?

Is the entry in the hosts file to dumbsite.com or www.dumbsite.com? For the type of test you're doing (i.e. via web browser) it's important that you specify the name exactly as it appears in the hosts file. And some browsers will try to "do the right thing" and prepend a www to the name.

Also, if your browser is configured to use a proxy, the hosts file will essentially be ignored.

gfunkdave Feb 27, 2015 1:28 pm

Using the hosts file for ad blocking has always seemed silly to me. It's really not designed for this. How about just using ....... Plus or a similar plugin? Also, OpenDNS will automatically filter out known malware domains. The best part about both is that you don't have to update their lists, like you would with a hosts file.

rdurlabhji Feb 27, 2015 2:52 pm

I've only used the hosts file for pranks. #2 in your post is pretty much correct as to how it works.

HDQDD Feb 27, 2015 3:20 pm

What OS? To make sure you have the right path to file...

In most OSes, the format is:

127.0.0.1 dumbsite.com
127.0.0.1 anotherdumbsite.com

You should be able to use ping or nslookup to verify that it works. In Windows and most *nix systems and on OS X it's effective as soon as you save the file.

Browser doesn't matter.

BigLar Feb 27, 2015 3:54 pm


Originally Posted by HDQDD (Post 24426984)
What OS?

Windows 7 and XP.

Originally Posted by HDQDD (Post 24426984)
In most OSes, the format is:

127.0.0.1 dumbsite.com
127.0.0.1 anotherdumbsite.com

The format is correct.

Originally Posted by HDQDD (Post 24426984)
You should be able to use ping or nslookup to verify that it works.

I tried pinging (command prompt) using the exact spelling as in the file and it substitutes the appropriate alias (if necessary), fills in the proper IP address, and proceeds to ping the right guy and get a response. Nslookup finds the right guy, too. Clearly it seems to be ignoring the file or I'm misusing it.

mikelat Feb 27, 2015 5:30 pm


Originally Posted by BigLar (Post 24427161)
Windows 7 and XP.
The format is correct.
I tried pinging (command prompt) using the exact spelling as in the file and it substitutes the appropriate alias (if necessary), fills in the proper IP address, and proceeds to ping the right guy and get a response. Nslookup finds the right guy, too. Clearly it seems to be ignoring the file or I'm misusing it.

What is the full path to the file your hosts file? Did you accidentally save it as .txt or something?

BigLar Feb 27, 2015 6:27 pm

Contrary to what I've been told, I did a reboot - at that time, the hosts file was read in, and now everything on the list winds up being unreachable (according to ping).

Which is what I wanted.

I generally put my computers to sleep rather than shut down, so I got out of the habit of rebooting. :)

LIH Prem Feb 28, 2015 6:27 am


Originally Posted by BigLar (Post 24427713)
Contrary to what I've been told, I did a reboot - at that time, the hosts file was read in, and now everything on the list winds up being unreachable (according to ping).

Which is what I wanted.

I generally put my computers to sleep rather than shut down, so I got out of the habit of rebooting. :)

that's weird, I don't have to reboot with win7. Changes to the hosts file are applied immediately. I just tested it with yahoo.com, entry in the file, ping used that, entry not in the file, ping used dns. No reboot, just edit the file.

I wonder if there's a policy for it somewhere, similar to nsswitch.conf?

Yeah, there is, post #2 in this thread:

http://h30499.www3.hp.com/t5/Systems...8#.VPHCl1PF-Qw

My values were the same as what he reported. Are yours different?

-David

Loren Pechtel Feb 28, 2015 10:42 am


Originally Posted by gfunkdave (Post 24426395)
Using the hosts file for ad blocking has always seemed silly to me. It's really not designed for this. How about just using ....... Plus or a similar plugin? Also, OpenDNS will automatically filter out known malware domains. The best part about both is that you don't have to update their lists, like you would with a hosts file.

Yeah, ....... updates automatically. Using the hosts file is something you have to update manually.

HDQDD Feb 28, 2015 11:48 am


Originally Posted by BigLar (Post 24427713)
Contrary to what I've been told, I did a reboot - at that time, the hosts file was read in, and now everything on the list winds up being unreachable (according to ping).

Yeah, that's because you're still running XP. Maybe if you submit a help ticket with MS, they'll fix it. :)

Alternatively, you could use: ipconfig /flushdns to flush the dns resolver cache.


All times are GMT -6. The time now is 3:17 am.


This site is owned, operated, and maintained by MH Sub I, LLC dba Internet Brands. Copyright © 2024 MH Sub I, LLC dba Internet Brands. All rights reserved. Designated trademarks are the property of their respective owners.