I want to route all the internet traffic of my phone through my VPN.

I configured OpenVPN on my htc Desire with Cyanogenmod through the integrated VPN settings dialog.

When I activate the Redirect-Gateway option, DNS resolution (e.g. google.com) doesn't work anymore. So not like others where the resolution of there local hostnames doesn't work (that wouldn't be a problem for me). The device hast still a connection to the internet (through the VPN) but it can't resolve domain names anymore.

The nameservers look correctly configured (adb shell):

# cat /etc/resolv.conf

I've also tested the OpenVPN Settings app but as soon as i add 'redirect-gateway' to the openvpn configuration file I get the same problem.

What could cause this problem?

3 Answers 3


I found now a solution myself:

First, cat /etc/resolv.conf isn't a valid way to display the used DNS servers under Android. Use getprop net.dns1 instead.

In my case the DNS server wasn't the Google server as set in /etc/resolv.conf, instead it was one of my ISP which accepts only requests from IPs in its network but my OpenVPN server is in another network.

To solve this issue i just modified /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf a bit:

# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.

    case "${new_domain_name_servers}" in
    "")   return 0;;

    for i in 1 2 3 4; do
        setprop dhcp.${interface}.dns${i} ""

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

    setprop net.dns1
    setprop net.dns2

case "${reason}" in
EXPIRE|FAIL|IPV4LL|RELEASE|STOP)                unset_dns_props;;

That will force the phone to always use the Google DNS servers for all connections (e.g. 3G, WiFi, OpenVPN, ...).

I've tested that for a few weeks now and it works perfect.


I just ran into the same problem. Everything works but dns.

I found before that my cell provider, Bell, blocks udp 53 to anything but their servers.

Maybe dns isn't going through openvpn on android but openvpn is changing the servers.

I noticed that some other apps didn't go through openvpn, like the play store.


I got it to work perfectly with 'openvpn for Android' app by playing with provided options within the app and not other messing around...with 'openvpn connect', it worked only for non market/os apps after manually setting : setprop net.dns1 xxx each time after a VPN connect... Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .