Editing hosts & hosts.editable has no effect

I’ve been adding some entries to ad-blocking in the /etc/hosts file (Sailfish 4.0.1.48) and this seems to have no effect at all (even after reboot). I have tried the same in the hosts.editable file with the same result. I thought maybe the thousands of entries (about 85000) I am adding hit a limit somewhere, so I tried adding a single line to the hosts file to check if that was respected, it was not either.

It is unclear to me whether I should be using the hosts or hosts.editable file for this. Also, is there any way to rebuild a DNS cache on Sailfish? I have tried restarting the Network from “Utilities” in the Sailfish settings with no effect.

Any hints would be much appreciated, thanks.

I am using these 4 default hosts lists that AdAway uses and am removing everything but the actual ad redirects to 127.0.0.1 or 0.0.0.0 so as not to disturb the two default entries in the Sailfish default hosts file. I am aware there are apps like Defender out there, but I would like to control my own hosts file with my shellscript and found Defender hangs while trying to download new hosts files (Defender is uninstalled). My hosts file looks like this, with of course thousands of more ad-blocking entries:

127.0.0.1		localhost.localdomain localhost
::1		localhost6.localdomain6 localhost6

# AdAway hosts
127.0.0.1 analytics.163.com

EDIT: Using the same hosts file in aliendalvik by having the entry:
lxc.mount.entry = /etc/hosts system/etc/hosts none bind,create=file 0 0
in /var/lib/lxc/aliendalvik/extra_config refer to the sailfish /etc/hosts file blocks ads as expected in Android apps just fine. So it really seems Sailfish has a DNS cache of its own somewhere I need to rebuild.

2 Likes

Please see


and

1 Like

Excellent, adding the nsswitch.conf did the trick. Thanks a lot! I have marked your response as the solution.

I guess this also means I will stick to modifying the traditional hosts file, as opposed to hosts.editable.

1 Like

Please see

1 Like

@peterleinchen sorry I can’t find any solution in all these links. Meanwhile we have SFOS 4.4.0.72, and the question remains, how to apply /etc/hosts’ content to all network traffic overriding caches and any other DNS servers, including tethering to also protect the devices connected to the Mobile Access Point.

edit: earlier I tried ‘Defender’ and Defender also was totally inoperative and did nothing. Therefore I assumed I made a mistake at installing time and couldn’t find a solution. Maybe this had the same reason as the not working /etc/hosts tweak.

What can I try now?

edit: A network reset by Sailfish Utilities is not sufficient, but a full reboot did it!
Now ‘Unable to connect’ to G**gle !!!

edit: Shall I better redirect unwanted adresses to 127.0.0.1 or better to 0.0.0.0, or elsewhere ?
(I guess it’s important that the requests really disappear without any trace, and not some logfile becomes fuller and fuller until overflow.)

Where is /etc/dnsmasq.conf on the Xperia 10 / SFOS 4.4.0.72? On the Volla it is present and I can edit it, but I can’t find this file on the Xperia 10.

Does anyone know?

edit: silly me! On this Xperia 10 dnsmasq simply was not installed. So I installed it, and /etc/dnsmasq.conf was present then. But it doesn’t work, so I have to open a new thread to this topic with an appropriate thread title.

The best solution for this purposes is to use dnscrypt-proxy .
Dnscrypt-proxy with blacklist, forward list, etc. is the most flexible and ‘must have’ privacy tool.

This is very very complex (too complex for me), and as I saw the many options and good explanations in dnsmasq.conf, I really hope that I can make it work by finding the right settings. Unexpected by me, I saw that dnsmasq is able to assign a defined IP address to a clients hostname. That’s a feature I really would like to have!

I am sorry to bring this thread up but the solution in this thread was not satisfying me. As @Seven.of.nine I did not get it what the solution is. So I looked up in the forum for a thread and found that discussion

Problem: [release notes] Koli 4.0.1 - #75 by martijntje
Explanation/Solution:
-Part 1 [release notes] Koli 4.0.1 - #119 by martinh
-Part 2 [release notes] Koli 4.0.1 - #125 by martinh

My /etc/nsswitch.conf and /etc/resolv.conf does exist, so as I understand @martinh my /etc/hosts file should be considered.

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
#

passwd:         db files
group:          db files
initgroups:     db [SUCCESS=continue] files
shadow:         db files
gshadow:        files

hosts:          files dns
networks:       files dns

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       db files
# Generated by Connection Manager
nameserver ::1
nameserver 127.0.0.1

I am not sure how to move one. Does anyone has an idea? I tested this even with a small /etc/hosts file, which just has an extra entry like this:
0.0.0.0 jolla.com
Still no success.

SFOS Version: 4.5.0.19
Default browser

Not sure which device you are on, but on a GS5/Rephone with @piggz port, the hosts file works with angelfish, but not with the Jolla browser with default configuration. I just add entries and ping test. I’ve been trying to configure jolla’s, as yet to succeed. My original thought is that our FF version is using DNS over HTTPS, but I’m not certain. Anyone know for sure?

With DNS alternative installed /etc/hosts works in Jolla’s browser. I’m not sure about default configuration.

Ah, that’s interesting. /etc/hosts works for ping/curl on the phone and for some web apps. why not the jolla browser. strange. Only DOH came to mind, but that doesn’t seem likely if the DNS alts work.

But I think we also have different phones/ports coming with different issues?

Ok, found it:

In the jolla browser go to

about:config
search dns
network.dns.offline-local to false.

The local browser is now using /etc/hosts. Edit: @Systematics try this. and use a couple of entries, not just jolla.com

6 Likes

A better option for testing purposes is to create unique domain to server you know. E.g I use raspberryPi audio player in local network and in /etc/hosts
192.168.0.100 raudio.home
Should http://raudio.home works in browser that means /etc/hosts works.

2 Likes

Thank you @poetaster , that is a really sneaky configuration setting. I am wondering if something changed in the past because I am pretty sure that my host file worked in the past.

Yeah, I tested it before with a really huge file. jolla.com was just an example because I don’t want to trigger any spam detection. I am trusting jolla, in my normal host file it is not blocked :smiley:

yeah, it worked fine up until 4.5, I think. In any case, I only noticed it stopped when installing 4.5 and then just cloning the hosts (raw.githubusercontent.com/StevenBlack/hosts/master/hosts) didn’t work. So I started digging around…

I played around today with the /etc/hosts file. Somehow I changed the ownership of the file to (probably copy the file with the wrong user, but I don’t know):
defaultu defaultu 126 Aug 6 16:33 hosts
After that, the browser was not able to start anymore (with network.dns.offline-local to false.). I was able to fix it via set the permissions and the ownership to:

stat -L -c "%a %G %U" /etc/hosts
644 root root

So, if someone is running into the same issue that is worth a try.

Just bit me to. But after

chown root:root /etc/hosts

and a reboot, back in business.