Opened 14 years ago
Closed 8 years ago
#7362 closed bug (fixed)
hosts file not utilized
Reported by: | mmadia | Owned by: | humdinger |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Kits/Network Kit | Version: | R1/Development |
Keywords: | Cc: | mdisreali@… | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
hrev40924. A hosts file in B_COMMON_SETTINGS_DIRECTORY/network/hosts
is not utilized, even after a reboot.
cd `finddir B_COMMON_SETTINGS_DIRECTORY` mkdir -p network cd network wget -O hosts http://www.mvps.org/winhelp2002/hosts.txt echo '...Hosts file installed.'
After a reboot, the entries in hosts will not resolve to 127.0.0.1.
Attachments (1)
Change History (16)
follow-up: 2 comment:1 by , 14 years ago
comment:2 by , 14 years ago
Cc: | added |
---|
Replying to axeld:
I am not using such an extreme hosts file, but I use one since forever, and it's working just fine for me. I would expect that Haiku (or rather BIND) may have problems with that particular hosts file, though.
I have used the same hosts file for years on Windows2k, WinXP, Vista, Ubuntu 8.04 and up, PC-BSD 7 and up, and Haiku. Haiku has always failed to utilize the host file. The size of the hosts file should not matter, it should just work.
by , 14 years ago
comment:3 by , 14 years ago
The attached hosts file works on Win2k, WinXP, Vista, Ubuntu8.04 and up, PC-BSD 7 and up, and Mac OS X, according to others. It does not work on any revision of Haiku.
comment:4 by , 14 years ago
This is essentially the same as ticket:3639, only that was from before the beos->system renaming.
Currently, I have the same hosts file in boot/common/settings/network and boot/common/etc and it is still not utilized. I have never experienced Haiku respecting any hosts file, regardless where it was placed.
follow-ups: 6 7 comment:5 by , 13 years ago
The hosts file works after being converted to unix line endings, but the resolver appears to always check dns first. If I move my resolv.conf file out of the way then these hosts will resolve to 127.0.0.1
comment:6 by , 13 years ago
Replying to augiedoggie:
The hosts file works after being converted to unix line endings, but the resolver appears to always check dns first. If I move my resolv.conf file out of the way then these hosts will resolve to 127.0.0.1
I moved the /common/settings/network/reslv.conf to the desktop and rebooted, but my hosts file did not seem to work.
Does Pe convert files to UNIX line ending?
comment:7 by , 13 years ago
Replying to augiedoggie:
The hosts file works after being converted to unix line endings, but the resolver appears to always check dns first. If I move my resolv.conf file out of the way then these hosts will resolve to 127.0.0.1
I confirm that's the normal behavior. The default order for hosts resolution by IRS's libbind.so used in Haiku is:
- Domain Name Server (DNS)
- Network Information Service (NIS), if active
- local (aka hosts file)
As the host names in this anti-ads/spams hosts file are all resolved by DNS first, it doesn't work as one will expect.
To change that, you must create an /etc/irs.conf as follow:
hosts local dns
Beware, considering the size of this hosts file, it could make *all* host name resolution a bit slower. And there is no system-wide cache, only a per-application cache.
Sadly, we didn't fixed this path, which should lives in /common/settings/network/irs.conf instead. I will do that eventually, except if someone else does it faster than me.
comment:9 by , 12 years ago
Can this be closed?
Or should we add an irs.conf (see #8320) and example hosts files so that users can just drop a hosts file in?
As for line endings: cat hosts.txt | tr -d '\r' > hosts
comment:10 by , 12 years ago
To note the following worked:
/boot/common/settings/network/irs.conf:
hosts local continue hosts dns
It would be nice for this to be documented somewhere on the installed system.
comment:11 by , 12 years ago
I have several concerns based on this ticket:
- I don't know why you would want a local hosts file checked last. On pretty much every operating system I've used you can add to a hosts file to override something out on the internet. This adblock host file is one example, but in my work I've also used it to make external websites I was testing resolve to a local host when testing things. I think we should either add a default irs.conf to the system to force local host resolving first or better yet override the defaults within the library.
- It is pretty ridiculous for the DNS library to choke on Windows line endings. The line ending should be irrelevant when parsing the hosts file. Haiku is not the sort of system where stupid things like that should break functionality.
- There should be a system-wide DNS cache, and everything in the hosts file should be pre-cached. Resolving DNS should not be adversely affected by even a hosts file as big as this one (559 KB.)
comment:12 by , 12 years ago
That's indeed how it should work. It's just a bit of work to get there :-)
comment:13 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I think this is solved since the switch to netresolv instead of libbind? At least I saw some people using host files.
comment:14 by , 8 years ago
I have no idea about irs.conf and other details commented in this ticket, but a hosts file works indeed. Much faster web browsing without all those ads everywhere, too. I also tried the hosts file attached to this ticket; it works as well. Close ticket?
comment:15 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Yes, the fact that the host files does override DNS queries means the irs file is not needed anymore and the behavior is as expected. Thanks for checking!
I am not using such an extreme hosts file, but I use one since forever, and it's working just fine for me. I would expect that Haiku (or rather BIND) may have problems with that particular hosts file, though.