lildebi icon indicating copy to clipboard operation
lildebi copied to clipboard

use DNS settings from Android

Open peat-psuwit opened this issue 11 years ago • 5 comments

In many network (including mine), the network administrators prohibit connecting public DNS server, making default setting in /etc/resolv.conf not works.

As we can read DNS settings by "getprop" command anyway, why don't we read it out and set it properly each time we boot up debian. I suggest following code:

echo "" > $mnt/etc/resolv.conf
i=1
dns=$(getprop net.dns$i)
while [[ $dns ]]; do
    echo "nameserver $dns" >> $mnt/etc/resolv.conf
    i=$(( $i + 1 ))
    dns=$(getprop net.dns$i)
done

We can also listen to network changes broadcast and run this snippet of code when the network situation is changed. See http://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html

peat-psuwit avatar Feb 24 '14 13:02 peat-psuwit

This definitely sounds useful. Do you have this working on your device? I think the way to do it would be to figure out how the /etc/network scripts get called on a pure Debian system, then reproduce that in Lil' Debi. Then people can customize their network setups in the normal Debian way.

eighthave avatar Feb 24 '14 14:02 eighthave

The android-androresolvd package ought to solve this, if I understand correctly. However, I can't run it, as I get "Cannot access system properties via ANDROID_PROPERTY_WORKSPACE environment setting". That env. variable exists in my android environment (e.g, by adb shell), but looks like it is getting cleaned up by time I get a shell on debian.

jfmcbrayer avatar Dec 05 '14 13:12 jfmcbrayer

There are probably a couple of other important env vars that don't make it though, like LD_LIBRARY_PATH. I wonder where they are being stripped.

eighthave avatar Dec 11 '14 10:12 eighthave

Has anyone figured out how to get androresolvd working yet?

forresthopkinsa avatar Mar 11 '15 06:03 forresthopkinsa

I have a Fairphone, first edition, which comes rooted by default. I get the same error "Cannot access system properties via ANDROID_PROPERTY_WORKSPACE environment setting". probing the environment variables yields:

root@phone:/# export declare -x ANDROID_ASSETS="/system/app" declare -x ANDROID_BOOTLOGO="1" declare -x ANDROID_DATA="/data" declare -x ANDROID_PROPERTY_WORKSPACE="8,49664" declare -x ANDROID_ROOT="/system" declare -x ANDROID_SOCKET_zygote="9" declare -x ANDROID_STORAGE="/storage" . . . root@phone:/#

Can I set the ANDROID_PROPERTY_WORKSPACE to something sensible (assuming the variable is wrongly set)? What is a sensible value?

Best regards,

George

gskillas avatar Feb 12 '16 08:02 gskillas