Members
  • Total Members: 14176
  • Latest: toxxxa
Stats
  • Total Posts: 42869
  • Total Topics: 16078
  • Online Today: 3377
  • Online Ever: 51419
  • (01. January 2010., 10:27:49)









Author Topic: Q: does anyone know of an Androïd 4.3+ automatic DNS changer tool? :(  (Read 18721 times)

0 Members and 2 Guests are viewing this topic.

devnullius

  • SCF VIP Member
  • *****
  • Posts: 3614
  • KARMA: 157
  • Gender: Female
    • SCForum.info
I need automatic DNS change app for Android 4.3 - but 4.3 re-implemented everything and I could not find a working program. Can you? I want my pandora back! :(

Technical background...

Copy Paste FROM: http://forum.xda-developers.com/showpost.php?p=44722857&postcount=6

17th August 2013, 11:03 PM  #6 

Browsing through the AOSP sources, I noticed that Android 4.3 incorporated a somewhat confusing series of commits  under the heading of "dns cache per interface," which effectively causes all Bionic DNS requests to be proxied through netd. This commit  is the most important element.

Here is the old implementation from Android 4.2.2 :

Code:
static struct hostent *
gethostbyname_internal(const char *name, int af, res_state res)
{
        const char *cp;
        char *bp, *ep;
        int size;
        struct hostent *hp;
        struct resolv_cache*  cache;
        res_static  rs = __res_get_static();

        static const ns_dtab dtab[] = {
                NS_FILES_CB(_gethtbyname, NULL)
                { NSSRC_DNS, _dns_gethtbyname, NULL },  /* force -DHESIOD */
                { 0, 0, 0 }
        };

        assert(name != NULL);

        switch (af) {
        case AF_INET:
                size = INADDRSZ;
                break;
        case AF_INET6:
                size = IN6ADDRSZ;
                break;
        default:
                h_errno = NETDB_INTERNAL;
                errno = EAFNOSUPPORT;
                return NULL;
        }

        rs->host.h_addrtype = af;
        rs->host.h_length = size;

[...]

        h_errno = NETDB_INTERNAL;
        if (nsdispatch(&hp, dtab, NSDB_HOSTS, "gethostbyname",
            default_dns_files, name, strlen(name), af) != NS_SUCCESS) {
                return NULL;
        }
        h_errno = NETDB_SUCCESS;
        return hp;
Note the use of the libc resolver. The library is issuing the DNS requests directly.

By contrast, here is the new Android 4.3  implementation:

Code:
// very similar in proxy-ness to android_getaddrinfo_proxy
static struct hostent *
gethostbyname_internal(const char *name, int af, res_state res, const char *iface)
{
        const char *cache_mode = getenv("ANDROID_DNS_MODE");
        FILE* proxy = NULL;
        struct hostent *result = NULL;

        if (cache_mode != NULL && strcmp(cache_mode, "local") == 0) {
                res_setiface(res, iface);
                return gethostbyname_internal_real(name, af, res);
        }

        proxy = android_open_proxy();
        if (proxy == NULL) goto exit;

        /* This is writing to system/netd/DnsProxyListener.cpp and changes
         * here need to be matched there */
        if (fprintf(proxy, "gethostbyname %s %s %d",
                        iface == NULL ? "^" : iface,
                        name == NULL ? "^" : name,
                        af) < 0) {
                goto exit;
        }

        if (fputc(0, proxy) == EOF || fflush(proxy) != 0) {
                goto exit;
        }

        result = android_read_hostent(proxy);
So by default, Android 4.3 will proxy the requests through netd (owned by UID 0). This can be verified by setting DBG to 1 in system/netd/DnsProxyListener.cpp, then watching logcat:

Code:
D/DnsProxyListener(  146): argv[0]=getaddrinfo
D/DnsProxyListener(  146): argv[1]=omg.yahoo.com
D/DnsProxyListener(  146): argv[2]=^
D/DnsProxyListener(  146): argv[3]=1024
D/DnsProxyListener(  146): argv[4]=0
D/DnsProxyListener(  146): argv[5]=1
D/DnsProxyListener(  146): argv[6]=0
D/DnsProxyListener(  146): argv[7]=^
D/DnsProxyListener(  146): GetAddrInfoHandler for omg.yahoo.com / [nullservice] / [nulliface] / 1489
D/DnsProxyListener(  146): GetAddrInfoHandler, now for omg.yahoo.com / (null) / (null)
D/DnsProxyListener(  146): argv[0]=getaddrinfo
D/DnsProxyListener(  146): argv[1]=l1.yimg.com
D/DnsProxyListener(  146): argv[2]=^
D/DnsProxyListener(  146): argv[3]=1024
D/DnsProxyListener(  146): argv[4]=0
D/DnsProxyListener(  146): argv[5]=1
D/DnsProxyListener(  146): argv[6]=0
D/DnsProxyListener(  146): argv[7]=^
D/DnsProxyListener(  146): GetAddrInfoHandler for l1.yimg.com / [nullservice] / [nulliface] / 1489
D/DnsProxyListener(  146): GetAddrInfoHandler, now for l1.yimg.com / (null) / (null)
As seen in the Android 4.3 code snippet, it is possible to temporarily revert to the old behavior by setting ANDROID_DNS_MODE to "local", causing Bionic to send the request through gethostbyname_internal_real(), the old implementation. On this system, the shell user is blocked from sending network traffic via netfilter, but the root user (which owns netd) has full network access:

Code:
shell@android:/ $ id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
shell@android:/ $ ANDROID_DNS_MODE= telnet google.com 80
telnet: can't connect to remote host (74.125.227.135): Connection refused
1|shell@android:/ $ ANDROID_DNS_MODE=local telnet google.com 80               
telnet: bad address 'google.com'
1|shell@android:/ $
In the former case (proxied request), the application was able to look up the hostname via netd, but could not send data traffic. In the latter case (direct request), the application was not able to look up the hostname at all.

It is possible to change the systemwide default by making a tweak to system/core/rootdir/init.rc and rebuilding your kernel image:

Code:
diff --git a/rootdir/init.rc b/rootdir/init.rc
index b6d7335..d0efc46 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -47,6 +47,7 @@ loglevel 3
     export ANDROID_ASSETS /system/app
     export ANDROID_DATA /data
     export ANDROID_STORAGE /storage
+    export ANDROID_DNS_MODE local
     export ASEC_MOUNTPOINT /mnt/asec
     export LOOP_MOUNTPOINT /mnt/obb
     export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
Maybe there is a better way to patch existing ROMs in place.

Written by cernekee: http://forum.xda-developers.com/member.php?u=5293221


... Karma!


Devvie


~~~ notemail@facebook.com ~~~

Conare nullius momenti videri fortasse missilibus careant
——
All spelling mistakes are my own and may only be distributed under the GNU General Public License! – (© 95-1 by Coredump; 2-013 by DevNullius)
More information about bitcoin, altcoin & crypto in general? GO TO  j.gs/7385484/btc

Cuisvis hominis est errare, nullius nisi insipientis in errore persevare... So why not get the real SCForum employees to help YOUR troubled computer!!! SCF Remote PC Assist http://goo.gl/n1ONa9

Samker's Computer Forum - SCforum.info


devnullius

  • SCF VIP Member
  • *****
  • Posts: 3614
  • KARMA: 157
  • Gender: Female
    • SCForum.info
I really hoped I was just being paranoïd and Google did not disable DNS changes "just" for protecting copyright.

So the only program tackling this, is now under Aware License. Read more here: http://forum.xda-developers.com/showpost.php?p=47323755&postcount=1

Back to DNS on Android 4.3+ A person / group of individuals were hard on their way of solving this problem... They WERE. Read why here: http://forum.xda-developers.com/showpost.php?p=37062006&postcount=3

Partial Copy Paste:

28/10/2013 -

Hi guys,

I have some very sad news.

As you may have noticed in the last few months, there has been a public attempt to denigrate this mod and XDA by external forces who are obviously against the concept of adblocking and DNS changing ( their entire control/sabotage of the internet is lost if you give users the ability to use external DNS ).

Today my friend died of a sudden illness the same that struck my mother in law last month. And the same time of her death some fake newbie posted here with a name similar to hers on my 1-Click thread. Sending a message of sorts.

I am in the meanwhile getting all sorts of thinly veiled threats.

The Adblock Plus website is under attack too.

I am going to raise this matter with the police. Hope they can find a pattern of these forum users and international corporate espionage rings run by the PR industry.

I regret to inform you that I need to stop development of this mod. If these people can stoop so low just to make money on superficial s**t like ads and take innocent lives, I can't fight this. I'm just a small-time hacker. I need to protect my family in whatever limited capacity I have.

Uploaded the last version with development as it was. Should be very usable with some noticeable usability improvements in the process and services ionice and renice and cgroup ( iffy ) space.

Uploaded source of the binaries.

License is BSD unless inherited from GPL.

Sorry for the terrible coding. Maybe some programmer can take it up and do something good with it.

Bye. Thanks a lot. Take care.

Good luck and god speed!

Idcrisis

Peace & karma,

devnullius

PS: what a story - curious if it holds up, but it reads legit :s
More information about bitcoin, altcoin & crypto in general? GO TO  j.gs/7385484/btc

Cuisvis hominis est errare, nullius nisi insipientis in errore persevare... So why not get the real SCForum employees to help YOUR troubled computer!!! SCF Remote PC Assist http://goo.gl/n1ONa9

devnullius

  • SCF VIP Member
  • *****
  • Posts: 3614
  • KARMA: 157
  • Gender: Female
    • SCForum.info
A different approach, not yet verified or tested by me. Not even sure if they are talking about droid 4.3+ ;p

But I do know that AutomateIt Pro has shell script extension... And there are shell script apps too that one maybe could use with AutomateIt Pro to execute a few scripts. Even further, edit the file /system/etc/ppp/ip-up and change the lines specified. That should allow the changes to stick through a reboot, and will take effect anytime you enable/disable the data connection (http://forum.xda-developers.com/showpost.php?p=23339423&postcount=4)

FROM: http://forum.xda-developers.com/showpost.php?p=23333968&postcount=1

How do you change the DNS, not for wifi, but for mobile data? Does it improve browsing performance?

Here is what I found out, thanks to zeppelinrox, on how to change the DNS for the droid charge, you can use script manager to run it every hour or 2 since if you loose connection or whatever the DNS will revert back to verizon. You can use whatever DNS you want. You can put it in the init folder but you need too add a sleep time like sleep 30 or longer play around with it and after reboot go to myresolver.info to check if the settings went through. The script below changes wifi, 3G and 4G DNS

#!/system/bin/sh
setprop dhcp.tiwlan0.dns1 208.67.222.222
setprop dhcp.tiwlan0.dns2 208.67.220.220
setprop net.ppp0.dns1 208.67.222.222
setprop net.ppp0.dns2 208.67.220.220
setprop net.dns1 208.67.222.222
setprop net.dns2 208.67.220.220
setprop net.rmnet0.dns1 208.67.222.222
setprop net.rmnet0.dns2 208.67.220.220
setprop net.pdpbr1.dns1 208.67.222.222
setprop net.pdpbr1.dns2 208.67.220.220

By Maurog84 (http://forum.xda-developers.com/member.php?u=3618356)

DO mention that all solutions I found up until now, only allows for ONE DNS server, not TWO... :S But I'll be happy with 1, for now ; -)

Karma!

devnullius
More information about bitcoin, altcoin & crypto in general? GO TO  j.gs/7385484/btc

Cuisvis hominis est errare, nullius nisi insipientis in errore persevare... So why not get the real SCForum employees to help YOUR troubled computer!!! SCF Remote PC Assist http://goo.gl/n1ONa9

devnullius

  • SCF VIP Member
  • *****
  • Posts: 3614
  • KARMA: 157
  • Gender: Female
    • SCForum.info
Still haven't solved this problem. I tried the newest ROM Toolbox Pro 6.0.3. with it's auto DNS changer tool. It fails, despite requesting root access.

:(

If anyone knows anything... Do let us know :) I miss Pandora!
More information about bitcoin, altcoin & crypto in general? GO TO  j.gs/7385484/btc

Cuisvis hominis est errare, nullius nisi insipientis in errore persevare... So why not get the real SCForum employees to help YOUR troubled computer!!! SCF Remote PC Assist http://goo.gl/n1ONa9

Samker's Computer Forum - SCforum.info


 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
Second Anti-Bot trap, type or simply copy-paste below (only the red letters):www.scforum.info:

Enter your email address to receive daily email with 'SCforum.info - Samker's Computer Forum' newest content:

Terms of Use | Privacy Policy | Advertising