Block unwanted servers and websites using hosts files on any system

Hello Everyone,

I have been trying to improve my privacy on a phone from the Meizu brand.
A Meizu Pro 6 exactly.

That idea leads me to catch the traffic going out of the phone.

In order to do so, I create a little host file.
This host file is for European rom users.
Note that it will not intercept all connections since some are IP direct.
I would be curious to compare it to your personal host files guys if you have any :slight_smile:
(For this brand or other brands)

the file :
https://pastebin.com/R6UJCEFq

1 Like

Hey @reinar I get your great idea and experiment :open_mouth: but do not fully understand how this “host file” is used. Perhaps you or @archje & @harvey186 e support can explain in simple terms just how any leakage would be confirmed. :face_with_monocle:

You mean a hosts file for blokada, or ??

Hello @Andy1,The goal of this post is first :
To understand that each line of the file is a server or group of server where this kind of phone is connecting when it is using the stock rom (By default).

Second goal :
To see if anyone has gone through the same process than me and created his own file :slight_smile:

Third goal :
Use this file on phones of the brand Meizu that do not have the luck to be supported by Lineage OS or Eelo. It prevent the phone to connect to servers and to log any data about the phone and his user.

I post it in this generic section because I know that alot of people have a phone non compatible with Eelo. This is a tool that may help them achieve a better level of privacy.

To use it, you need to put it in /system/hosts. Unfortunately, you need a root access to do so in Android.
@harvey186 Of course an other option is to use an application like blokada, but you will have to start it automatically on startup.

The file can be used to bypass the dns service. This is very useful because we can send some request to an invalid adress. For example if you want to block google on your phone or computer, you just have to add the following line : 127.0.0.1 google.com
It will then redirect any google request to 127.0.0.1 which is your own device.

Hope that is clear, please tell me if you have any questions :relaxed:

1 Like

Thanks @reinar for the detailed explanation. I understand your mission much better now.
Here in UK we have public Channel4 on Freeview TV station which also streams More4 but I cannot watch this content because of DNS issue on ubuntu and Trisquel with three different browsers so far. You say this could help bypass the DNS service which should solve my problems? I realize that this was not your first goal but may I thank you and apologise for drifting off topic.

@Andy1 Your problem looks really curious. There is no chance in my opinion that your problem come from the DNS since it is a very reliable service. I would tend to think that it is a DRM issue or a plugin issue. How can you be sure that it come from DNS ?

Hello @reinar,
the subject is new territory for me. Since I am curious, I’ve a Samsung with frew ‘factory reset’ stockROM Android 8.0.0 and product code DBT from Germany. With TWRP Recovery I do mount /system. There is no /hosts folder. Where do I get my “personal host files”?

Do you have links to online articles so that I can read up on the subject?

Hello @archje
Thank you for your interest !
First, I suggest you to read this article : https://vitux.com/linux-hosts-file/

On Android /system/etc/hosts is a file and with TWRP you should be able to modify it !

The fact is that the file is probably empty for you now !
If you modify it, you will be able to modify the way your phone interact with the internet (mostly)

Maybe Samsung modify the system and remove it… can you confirm that you see the file in /system/etc/hosts?

Yes @reinar, the directory /system/etc/hosts exists - but without files (empty).

Can we please continue corresponding tomorrow. It’s after midnight and I’m already sitting in front of the screen too long again. I should better go to sleep now.

Of course @archje Good night :slight_smile:

Thanks @reinar, it’s a a well understood article. Interesting is also:

There are also some predefined block lists available that you may use in your hosts file: https://github.com/StevenBlack/hosts

Now I’m surfing with the pre-installed web browser G°°chrome on websites of the e.foundation, among others > What a Meizu phone is doing.

hosts_reinar_meizu-test_1 twrp_hosts

The file hosts contains only these two entries:

127.0.0.1       localhost
::1             ip6-localhost 

DNS name resolution of my router (Cable > WLAN > Samsung Phone)

alternative

  • DNSv4 server 80.241.218.68 | dismail.de (with DNS-over-TLS as well as advertising, tracker and malware filter)

  • DNSv6 server 2a02:2970:1002::18 | digitalcourage e. V. (DNS-over-TLS)

alternative

  • DNSv6 server 2a02:c205:3001:4558::1 | dismail.de (with DNS-over-TLS as well as advertising, tracker and malware filter)

@reinar, how does our experiment continue?

@archje Wow, this is already a very nice setup you got there !
Personnaly I use DNS over TLS on my browsers but not on my router since it does not support this kind of modications.

In your case, you need to create your own hosts file and to fill it with the things you want to block !

Let’s start with this basic instruction :

127.0.0.1 localhost
::1 ip6-localhost

127.0.0.1 google-analytics.com

To add it to your host file :

create a new file inside /sdcard : hosts.new
Fill the file with the instructions and save ! (You can fill the file directly on your phone or copy it from your computer)

Then, launch TWRP, mount /system and do this command :

mv /sdcard/hosts.new /system/etc/hosts

This will replace your hosts file.

Now you can try to go on google-analytics.com on your phone and check if it is effectively blocked !

:slight_smile:

Hej @reinar, this idea is so simple, so good!

I first tried it with my Wind°ws host machine. Without having changed the empty file hosts, the website google-analytics…com is not found by my system (host.jpg #1)

Page was not found

The connection with the server google-analytics.com failed.
[..]
Try again

Next I’ll try: https://support.google.com/. The web page opens immediately (hosts.jpg #2).

C:\Windows\System32\drivers\etc\hosts.[data file]

Now I enter in the file hosts: 127.0.0.1 support.google.com and save it.

Next, I clear browser cache and call the website again. This time I get an error message:
Error: Connection failed (host.jpg #3)

Since my knowledge of web networks is extremely limited, I will ask you once again in simple words: by this forwarding of the original hostnames to my internal IP addresse(s), no external contact to the addresses is established, @reinar?

1 Like

Well done @archje

You are absolutely right ! In your case when you are connecting to support.google.com, the computer send the request to itself instead of the internet. (127.0.0.1 is an address used when the computer want to talk to himself in simple words).

I see that your computer language is deutch, so I guess english is not your first language ?

If you want to see what really append on the network and learn about it I strongly suggest you to install a program called Wireshark on your computer :slightly_smiling_face:

Here is the link : https://www.wireshark.org/

Try it !

1 Like

Thank you! I’ill try it.


@reinar,
my idea is: Change the title of your thread so that our /e/ user friends don’t only think of Meizu & China and many more users read it: Block a Website simple; e.g. What a Meizu phone is doing


One more question: Which /e/ phone do you use?


@archje Change the title seems like a good idea !

I suggest : Block unwanted servers and websites using hosts files on any system.

But I do not know how to change the title on discourse…

I am using an old nexus 5 as my main phone, /e/ is working very well on it actually, haven’t seen any bug.
I’m considering buying a galaxy S10 but /e/ does not support it and i am not sure that I want to root the phone or install TWRP to change stuff…

What do you think about that ? You are the Samsung expert here :slight_smile:

Hi @reinar, changed the title of the post as required.

1 Like

:+1: Block unwanted servers and websites using hosts files on any system :ok_hand:


@reinar, my personal favorite of the Samsung’s supported by /e/ OS is the Galaxy S8 SM-G950F “dreamlte” and (S8+ SM-G955F “dream2lte”).

Why?
Like performance of the Galaxy S8 is more than adequate (at least as far as my needs are concerned)

Because an official /e/ OS version 9-pie is available for the S8.

(Because for the S8+ the /e/ OS version 9-pie will be available soon. The tests¹ are already running.)

1 Like

I use this one, i even pay the guy once a year because i love the list, no it’s not me haha :grinning:. I wrote a little program some time ago to push it to my phone to make my life easy. I would love to have this hosts file embedded in /e/. It works great, even with use of VPN, the hosts file is queried first.

Hi @Manoj Thank you :blush:

@archje : Thank you for the details :slight_smile:

Actually, there are multiple factors that can influence my decision but I think I need to wait a little bit more since I buy my last phone four years ago. Five years between each phone seems good for me in an ecological approach.