Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.23k stars 571 forks source link

Issue with using Pi-hole as its custom DNS #15

Closed Zero3K closed 6 years ago

Zero3K commented 7 years ago

Some ads aren't being blocked when using a Raspberry Pi that has Pi-hole running as the custom DNS. I added the lists that are in the app (which is called Blokada) that I am using on the tablet (which does block the problematic ads) but they are still showing up every so often in the "Free Video chat online" app (NSFW).

rom1v commented 7 years ago

Some ads aren't being blocked when using a Raspberry Pi that has Pi-hole running as the custom DNS

Is it related to gnirehtet?

Zero3K commented 7 years ago

I did some testing. It turns out to be a problem with gnirehtet since the ads are blocked after adding the blocklists I was using in Blokada to the Pi-hole and dissbling Blokada (thereby using only the Pi-hole to block ads).

rom1v commented 7 years ago

I don't really know all the tools you are talking about, but gnirehtet just use the DNS servers you provide. It is not aware of any blocking-ad related stuff.

Zero3K commented 7 years ago

I know. I used the IP of the Pi-hole as the custom DNS server. It seems like not all DNS queries are using it. Otherwise, those ads would have been blocked.

Zero3K commented 7 years ago

So, it seems like it should be fixable.

rom1v commented 7 years ago

Maybe your Android device/app already resolved this address and cached it, so that it did not requested it again to the DNS server when you loaded the page.

Otherwise, you can check the UDP connections in the logs (compile the last version though, the last release does not log correctly UDP requests), they are probably DNS requests. This may help to follow DNS requests.

For further investigation, you could increase the log level to VERBOSE to print the packets data.

Zero3K commented 7 years ago

I tried fixing it by using two entries of the same IP in the command line parameter for the relay.jar. It didn't help in fixing it. Now to try increasing the log level to VERBOSE by compiling the latest source code. After running the latest build for a bit, I will reply with the more detailed log compressed as a ZIP archive. By the way, I've been noticing that the app is crashing while using the reverse tethering connection when it normally doesn't.

Zero3K commented 7 years ago

I upgraded to the latest build. Now the custom DNS parameter is no longer working.

EDIT: I fixed the issue by manually changing the DNS server that is in the GnirehtetService.java file located in \app\src\main\java\com\genymobile\gnirehtet.

EDIT2: Maybe a file (such as gnirehtet.conf) could be used to specify its configuration instead of relying on command line parameters.

EDIT3: I am attaching the log as promised to see if there's any improvements that can be done to it (In regards to the app, I am getting a never-ending loading circle in the list of users that are currently online every so often along with crashing I mentioned).

gnirehtet log.zip

rom1v commented 7 years ago

I upgraded to the latest build. Now the custom DNS parameter is no longer working.

Please give more details. I just try it again, it works here.

Zero3K commented 7 years ago

I am trying the command in Windows 7. The command line I am using is "C:\Program Files\Java\jre1.8.0_112\bin\java.exe" -Xms200M -Xmx200M -jar relay.jar --esa dnsServers 10.0.1.85 > gnirehtet.log.

rom1v commented 7 years ago

The command line I am using is "C:\Program Files\Java\jre1.8.0_112\bin\java.exe" -Xms200M -Xmx200M -jar relay.jar --esa dnsServers 10.0.1.85 > gnirehtet.log.

The DNS servers must be configured on the Android-side (the client creates the requests), so:

adb shell am startservice -a com.genymobile.gnirehtet.START --esa dnsServers 10.0.1.85

The relay server does not accept any parameters (it ignores them).

Zero3K commented 7 years ago

Heh, it was that easy after all. Thanks for telling me how to get it to work. Maybe you can add info on how to set it to the readme.

rom1v commented 7 years ago

Was this the root cause of this issue?

Zero3K commented 7 years ago

Yes. Now to figure out the issue with the never-ending loading circle, etc.

Zero3K commented 7 years ago

So can you figure that out or not?

rom1v commented 7 years ago

So can you figure that out or not?

You mean, the reason why you have an infinite progress bar on your application I know nothing about? No, I can't figure that out ;-)

Zero3K commented 7 years ago

Well, you could try it out and see what happens.

Zero3K commented 7 years ago

Maybe the app I mentioned is having the same issue as the ones I made issues about. I'll go ahead and close this one since the main reason for it has been figured out. Hopefully the app works when the other ones work properly.

Zero3K commented 7 years ago

I am attaching a log with its level set to debug to see if that helps fix the issue with the app I mentioned.

gnirehtet log.zip

rom1v commented 7 years ago

I have no idea how to correlate what you observe (an infinite progress bar, when?) and 20 minutes of logs.

I can only see that sometimes, for some reasons, Android is trying to connect to the same IP as your DNS server (10.0.1.85) on port 443, but the connection fails. It works only on port 53 (DNS requests) and port 80 (you have probably an HTTP server there).

Zero3K commented 7 years ago
  1. When viewing the user list after backing out of a chat (Its random though).
  2. Yes, Pi-Hole is a Web Server (to show the Web GUI) and a DNS Server. I agree that the port 443 connection is odd.
Zero3K commented 7 years ago
  1. Like I wrote in another issue, the connections to port 443 of the custom DNS are because it is redirecting the ads which are displayed via HTTPS to itself in order to block them.
Zero3K commented 7 years ago

Oh, maybe it doesn't handle timeouts that well. So, it keeps trying to connect with no success.

Zero3K commented 7 years ago

Is that an actual problem or not?

rom1v commented 7 years ago

I don't think so. I have no concrete element indicating that gnirehtet causes a problem here.