FORUMS
Remove All Ads from XDA
H10 Turbo

[GUIDE] How to Change DNS in Android Device (8 methods)

828 posts
Thanks Meter: 1,250
 
Post Reply Email Thread
6th July 2017, 10:48 AM |#11  
Member
Thanks Meter: 3
 
More
Help please,
Do u guys think dns changer app still needed if dns already change through build prop( kernel adiutor)? Or mod app like fly on mod?

Feels like its redundant
 
 
21st July 2017, 10:39 PM |#12  
Senior Member
Thanks Meter: 42
 
More
Is it possible to change dns host name permanently?
So it wont be changed to default after reboot..
26th August 2017, 11:16 AM |#13  
Senior Member
Thanks Meter: 30
 
More
@GokulNC

How to change the DNS ADDRESS with help of creating dumpy VPN service without help of any application .

With help of application -
U list out in non - root app list
Like
https://play.google.com/store/apps/d...gon.dnschanger
That app use dumpy vpn for dns change

But
why we app ??

Please try to discover the configuration of vpn..
The Following User Says Thank You to jiojio For This Useful Post: [ View ] Gift jiojio Ad-Free
2nd September 2017, 07:58 PM |#14  
Junior Member
Thanks Meter: 0
 
More
Hi, I have a question.
Can you tell me if this changes will be applied also to DNS of Mobile Data?
18th October 2017, 08:12 PM |#15  
Junior Member
Thanks Meter: 2
 
More
Dns
13th November 2017, 08:34 PM |#16  
Member
Thanks Meter: 2
 
More
I did change Dns regular interface for Android Tv but Dns leak test still shows Isp Dns. Why?
30th January 2018, 06:36 PM |#17  
Member
Thanks Meter: 9
 
Donate to Me
More
Quote:
Originally Posted by GokulNC

Here is a compilation of different ways to change/set the DNS Server in Android Devices

In this thread, I'll be setting the DNS Servers to 8.8.88 & 8.8.4.4 (Google DNS).
You can use any DNS server of your wish.

FOR NON-ROOTED DEVICES:



Method 1: (by changing WiFi Settings)

Note: For some devices, this will work only if you can set a static IP.

1. Go Settings->WiFi
2. Long press the Network you're connected to, and tap 'Modify Network'.
3. Check 'Advanced'. (may not be required in some phones)
Switch the IP settings from DHCP to Static.
Add required DNS servers to the entries for DNS 1 and DNS 2.
4. Click 'Save'
(Don't worry about the editing the IP address as the Android device may fill in the IP address it has acquired through DHCP.)

Google DNS


Method 2: (Easiest Method using app)

You could just use any app like:
1. Engelsiz : DNS Changer
2. DNS Changer (NO ROOT)
3. DNS Changer (no root 3G/WiFi)
4. DNSet
5. DNS Changer
(or any other app in Play Store.)
(Some apps may require root access)


FOR ROOTED DEVICES:

Easiest way:
The best apps I would recommend to do this automatically are:
1. Override DNS (Root)
2. Set DNS
3. DNS + DNSCrypt Manager
4. DNS Forwarder

Method 3: (by editing DNS config)

1. Open the file 20-dns.conf from /etc/dhcpcd/dhcpcd-hooks/ using a Text Editor (I use ES File Explorer)
2. Add this line to the beggining & reboot device:
Code:
new_domain_name_servers="8.8.8.8 8.8.4.4 $new_domain_name_servers"
So, finally the script finally looks something like this:
Code:
##THIS CAN VARY slightly FOR DIFFERENT ROM BUILDS
# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.

new_domain_name_servers="8.8.8.8 8.8.4.4 $new_domain_name_servers"

if [[ $interface == p2p* ]]
    then
    intf=p2p
    else
    intf=$interface
fi

set_dns_props()
{
    case "${new_domain_name_servers}" in
    "")   return 0;;
    esac

    count=1
    for i in 1 2 3 4; do
        setprop dhcp.${intf}.dns${i} ""
    done

    count=1
    for dnsaddr in ${new_domain_name_servers}; do
        setprop dhcp.${intf}.dns${count} ${dnsaddr}
        count=$(($count + 1))
    done

    separator=" "
    if [ -z "$new_domain_name" ]; then
       separator=""
    else
        if [ -z "$new_domain_search" ]; then
            separator=""
        fi
    fi
    setprop dhcp.${interface}.domain "${new_domain_name}$separator${new_domain_search}"
}

unset_dns_props()
{
    for i in 1 2 3 4; do
        setprop dhcp.${intf}.dns${i} ""
    done

    setprop dhcp.${interface}.domain ""
}

case "${reason}" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)       set_dns_props;;
EXPIRE|FAIL|IPV4LL|RELEASE|STOP)                unset_dns_props;;
esac


This is a permanent change. (& sets only for WiFi)
Remove that added line to undo the changes.
(Source: http://forum.xda-developers.com/show...82&postcount=7 )


Method 4: (by changing DNS properties using Terminal Emulator)

Note: This may not work in Android 4.4 and above devices.

1. Open Terminal Emulator and type:
Code:
getprop | grep dns
Terminal: getprop | grep dns

2. Note down all the properties related to dns1, dns2.
These are the properties you need to set to change the DNS Server.
Use the following commands in Terminal Emulator to set them (using setprop):
Code:
su
setprop dhcp.wlan0.dns1 8.8.8.8
setprop dhcp.wlan0.dns2 8.8.4.4
setprop net.dns1 8.8.8.8
setprop net.dns2 8.8.4.4
Other optional properties for mobile networks (may vary with devices) (rmnet0 for 3G I guess)
Code:
setprop net.ppp0.dns1 8.8.8.8
setprop net.ppp0.dns2 8.8.4.4
setprop net.rmnet0.dns1 8.8.8.8
setprop net.rmnet0.dns2 8.8.4.4
setprop net.pdpbr1.dns1 8.8.8.8
setprop net.pdpbr1.dns2 8.8.4.4
Setting DNS for very older devices:
Code:
setprop ro.kernel.android.ndns 2
setprop dhcp.eth0.dns1 8.8.8.8
setprop dhcp.eth0.dns2 8.8.4.4
(You may similarly set dns3 & dns4, but that's not necessary)

These properties get reset to the original values upon reboot..
So, to keep these changes permanent, add the required commands to init.d
(Source: https://github.com/ukanth/afwall/wik...ng-default-dns )


Method 5: (by using iptables command)

1. Open Terminal Emulator and type the following:
Code:
su
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53 || true
iptables -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53 || true
iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 8.8.8.8:53
iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 8.8.8.8:53
(you may also use this as AFWall+ Custom Script)

For more detailed info and better understanding, click here.

These properties get reset to the original values upon reboot..
So, to keep these changes permanent, add the required commands to init.d


Method 6: (by editing resolv.conf)

Note:
I think this method works only for old devices. Nothing wrong in trying

1. Open resolv.conf from /system/etc/ using a Text Editor (I use ES File Explorer)
(If there's no such file, create it and try.)
2. Modify the nameservers in the file to your desired DNS servers.
The file finally looks like this:
Code:
nameserver 8.8.8.8
nameserver 8.8.4.4
This change is permanent..
So, it's better to backup the original resolv.conf before editing.
(Source: https://butterflydroid.wordpress.com...android-phone/ )


Method 7: (by using ndc resolver command)


1. Open Terminal Emulator and type the following:
Code:
su
ndc resolver flushif ## to flush old DNS servers
ndc resolver flushdefaultif ## to flush resolver
ndc resolver setifdns <iface> <domains> <dns1> <dns2> ... ## Add the new servers
ndc resolver setdefaultif ## Set as the default device
This may vary for different Android Versions, so check this also..

These properties get reset to the original values upon reboot..
So, to keep these changes permanent, add the required commands to init.d


Method 8: (by using DNSCrypt command)


Hit the 'Thanks!' button if you found this helpful.
Leave a reply if you need any help
Do leave a reply if any of these methods worked on your device...

I am trying to use method #3 but I dont have dhcpcd folder ... What to do? My device is rooted and in es manager root explore is checked...
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20180130-193403.jpg
Views:	542
Size:	236.6 KB
ID:	4404551  
14th February 2018, 02:48 AM |#18  
Junior Member
Thanks Meter: 0
 
More
Nice guide, if you have a Raspberry Pi install Pi-Hole on it, then set your home ip as DNS server on your phone/tablet and you'll have have adblocker on your phone/tablet.
31st March 2018, 03:04 PM |#19  
drummond's Avatar
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by syamsoul

i'm on Android 6.0.1 and the iptables method works!

This thread has no other occurrence of "iptables" - would you mind including a reference.
I'm wasting far too much time reading solutions that don't work on CM13 - Android 6.0.1.
2nd April 2018, 02:43 AM |#20  
Senior Member
Flag Glasgow
Thanks Meter: 183
 
More
Quote:
Originally Posted by drummond

This thread has no other occurrence of "iptables" - would you mind including a reference.
I'm wasting far too much time reading solutions that don't work on CM13 - Android 6.0.1.

OP - Rooted Devices - Method 5 - it's right there, page 1.
There's an app too.
How much time can that waste?
(If it takes too long to go back one page, the OP is quoted just above your post)
2nd April 2018, 06:47 PM |#21  
drummond's Avatar
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by Boolian

OP - Rooted Devices - Method 5 - it's right there, page 1.
There's an app too.
How much time can that waste?
(If it takes too long to go back one page, the OP is quoted just above your post)

It's unfortunate the discussion combines unrooted and rooted. Mine is unrooted. FYI I had read page 1 - Wartickler mentions 6.1.x problems and asks what version (no reply). syamsoul said "iptables" works on 6.0.1 - and he didn't reply to my query.
It's also unfortunate that you thought criticism would help answer the question.
FYI the link to Universal Init.d is broken.
Post Reply Subscribe to Thread

Tags
change dns, dns, dns settings, modify dns, set dns

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes