Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf
# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.
set_dns_props()
{
case "${new_domain_name_servers}" in
"") return 0;;
esac
count=1
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
count=1
for dnsaddr in ${new_domain_name_servers}; do
setprop dhcp.${interface}.dns${count} ${dnsaddr}
count=$(($count + 1))
done
setprop dhcp.eth0.dns1 208.67.222.222
setprop dhcp.eth0.dns2 208.67.220.220
}
unset_dns_props()
{
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
}
case "${reason}" in
BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;;
EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;;
esac
#DNS
setprop ro.kernel.android.ndns=1 #choose 1 or 2
net.dns1=208.67.222.222
net.dns2=208.67.220.220
net.eth0.dns1=208.67.222.222
net.eth0.dns2=208.67.220.220
net.rmnet0.dns1=208.67.222.222
net.rmnet0.dns2=208.67.220.220
dhcp.tiwlan0.dns1=208.67.222.222
dhcp.tiwlan0.dns2=208.67.220.220
net.ppp0.dns1=208.67.222.222
net.ppp0.dns2=208.67.220.220
net.pdpbr1.dns1=208.67.222.222
net.pdpbr1.dns2=208.67.220.220
#!/sbin/sh
if grep -q dns1 /system/build.prop ; then
echo "already applied, no changes made"
else
echo "net.dns1=208.67.222.222" >> /system/build.prop
echo "net.dns2=208.67.220.220" >> /system/build.prop
echo "net.rmnet0.dns1=208.67.222.222" >> /system/build.prop
echo "net.rmnet0.dns2=208.67.220.220" >> /system/build.prop
echo "dns properties added to default.prop"
fi
# For CWM.
#!/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
@CHEF-KOCH

This comment has been minimized.

Copy link
Owner Author

CHEF-KOCH commented Sep 7, 2014

On Android <4.4
/system/etc/ppp/ip-up can also be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.