bparmentier / DNSSetter

Set custom DNS servers on Android (not maintained at the moment!)
Other
36 stars 9 forks source link

Set DNS on boot/IP change #1

Open bparmentier opened 9 years ago

bparmentier commented 9 years ago

Currently, DNS servers are overridden after each reboot/IP change/reconnection. We should find a method to make it persistent. I tried adding the setprop commands in /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf but this script doesn't seem to be called.

breversa commented 9 years ago

Alternatively, if DNSsetter could remember the DNS servers IPs instead of having to input them each and every time, that would be a start. :-)

Applying the changes would then only require the tap of one button. :-)

mimi89999 commented 9 years ago

The "Set DNS on boot" feature would be useful.

revuwa commented 8 years ago

The app https://github.com/otakuchiyan/DNSman has the feature to survive a reboot and / or a (mobile data) IP change. Probably you could borrow some relevant code snippets, if you like.

ZatsuneNoMokou commented 8 years ago

@revuwa This app (DNSman) only work on wifi networks, because of some Android "security" things. I see that on the description of DNS man on F-Droid But one thing that could be useful, is a widget / shortcut that could re-apply the last used DNS. That way, it could be much faster to do it than opening the app each time we need to re-change the DNS.

revuwa commented 8 years ago

@fullinterest Thanks, but how did you hit on that? I'm using DNSman for my 3G mobile data connection for some weeks now, without any problems. I'm interested on where did you see the "[...] some Android 'security' things" part exactly? IMHO the F-Droid description is mistakable, and for sure just took from the initializing thread owner: https://f-droid.org/forums/topic/dns-man/

AFAIK to use your own DNS server(s) on Wi-Fi, you could simply set it through the Wi-Fi connection settings and don't need an app for that. So mobile data should be the target in my eyes. But if you travel your connection interrupts very often and resets the DNS servers to the provider default ones. So IMHO, a widget or shortcut doesn't make sense to me. (Just in case you want to use the app for your Wi-Fi DNS instead; but like I said, this shouldn't be the use case, or am I wrong)?

ZatsuneNoMokou commented 8 years ago

I don't remember where I saw, but I remember that there's reason that they don't put a setting to change settings on mobile data, unlike wifi networks.

And don't know how it work, but currently, on my phone using f-droid 0.96, the description DNS man is "Change the used DNS server for specific wifi networks."

I just don't stay for long on WiFi network, so each time I switch on and off, the dns get changed again.

bparmentier commented 8 years ago

It should be possible to receive a broadcast intent each time there is a change in connectivity and execute the setprop commands.

I will try to implement this, but as this app doesn't seem to work anymore on my phone with the currently used method, I can't really test it.

ZatsuneNoMokou commented 8 years ago

Well, I did that in another way, I did a sh script, and I use SManager that allow to execute as root script on Net change events.

You know how the ndc method works?

bparmentier commented 8 years ago

So I guess that's what the app you mention does: it registers a broadcast receiver for android.net.conn.CONNECTIVITY_CHANGE and execute your script. The principle is the same.

I didn't have much success with the ndc method for now as it is not documented anywhere, but I listed the commands in the wiki, for each Android version.

ZatsuneNoMokou commented 8 years ago

And the setprop way will be removed in the future? Because you say it doesn't work on your phone

bparmentier commented 8 years ago

From what I read, DNS is managed by the netd daemon now (since Kit Kat, or around). You can interact with this daemon through the ndc command.

The property-based method does not seem to be used anymore (you could retrieve the dns values with getprop). But what is weird is that the net.dns[0-1] properties are still set when the connection change (I'm on Lollipop).

What Android version are you running ?

ZatsuneNoMokou commented 8 years ago

I'm running 4.4.4 version of android

bparmentier commented 8 years ago

And setprop is working for you?

ZatsuneNoMokou commented 8 years ago

Well, the setprop seem to be able to define the dns because getprop (and your app) show my custom dns, I dunno if there's a command on android to make sure of the dns used like dig on linux

bparmentier commented 8 years ago

Our discussion is going off the current issue. I answered you in #6.

I will first fix this issue for people for whom the application works, then I'll try to address the other issue.

ZatsuneNoMokou commented 8 years ago

Oh, sorry

oblique commented 8 years ago

Any news about this feature?