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)

hosts (155.1 KB ) - added by Disreali 14 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 by axeld, 14 years ago

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.

in reply to:  1 comment:2 by Disreali, 14 years ago

Cc: mdisreali@… 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 Disreali, 14 years ago

Attachment: hosts added

comment:3 by Disreali, 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 Disreali, 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.

comment:5 by augiedoggie, 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

in reply to:  5 comment:6 by Disreali, 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?

in reply to:  5 comment:7 by phoudoin, 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:

  1. Domain Name Server (DNS)
  2. Network Information Service (NIS), if active
  3. 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:8 by axeld, 13 years ago

Moved irs.conf to /boot/common/settings/network in hrev42643.

comment:9 by Ziusudra, 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 mmadia, 12 years ago

To note the following worked:

/boot/common/settings/network/irs.conf:

hosts local continue
hosts dns
protocols local

It would be nice for this to be documented somewhere on the installed system.

edit: added "protocols local", as mentioned in #8320, as I experienced the same issue.

Last edited 12 years ago by mmadia (previous) (diff)

comment:11 by leavengood, 12 years ago

I have several concerns based on this ticket:

  1. 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.
  1. 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.
  1. 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 axeld, 12 years ago

That's indeed how it should work. It's just a bit of work to get there :-)

comment:13 by pulkomandy, 8 years ago

Owner: changed from axeld to humdinger
Status: newassigned

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 humdinger, 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 pulkomandy, 8 years ago

Resolution: fixed
Status: assignedclosed

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!

Note: See TracTickets for help on using tickets.