This is my first post, so hopefully I am doing it right. I am still a complete noob at Raspberry Pis, so bear with me here...

Here is the story. I followed these tutorials on creating a WiFi hotspot, then a VPN router on a Raspberry Pi 3.

WiFi hotspot tutorial: https://pimylifeup.com/raspberry-pi-wireless-access-point/

VPN router tutorial: https://pimylifeup.com/raspberry-pi-vpn-access-point/

Everything works, except there are DNS leaks. I followed the steps very carefully and even reinstalled Raspbian multiple times. On my final reinstall, I compared it to the original Raspbian guide: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

There are still DNS leaks on all devices that connect to the VPN router. This did not used to happen. However, ever since it began happening, it has kept happening ever since.

Other troubleshooting steps I have tried:

  • Edit /etc/resolv.conf on the router to only allow the VPN provider's DNS servers (does not work)
  • Edit /etc/resolv.conf on a client (temporary fix, lost on reboot and only affects 1 host)
  • Added:

script-security 2

up /etc/openvpn/update-resolv-conf.sh

down /etc/openvpn/update-resolv-conf.sh

to the VPN config file (works only intermittently). openvpn-update-resolv-conf was already installed by default (https://github.com/alfredopalhares/openvpn-update-resolv-conf)

Is there any permanent fix to only allow the VPN provider's DNS servers to resolve hostnames and block all ISP attempts at DNS resolution?

This is the closest thing I could find, but it also did not help: https://community.openvpn.net/openvpn/wiki/Pushing-DNS-to-clients

Thank you for your time, and if you need any more information just let me know.

  • Why not post your OpenVPN configuration file ? One directive that could help in your situation is block-outside-dns (see this post) but there is a chance that the client will not enforce certain settings pushed by the VPN server. The behavior can be OS-dependent (Windows & Linux) and also network interface-dependent. What happens if the VPN connection drops due to a network issue ? I could imagine that the client restores default settings, and the leaks happen.
    – Kate
    Commented Mar 10, 2020 at 19:57
  • 1
    I have some firewall rules on my linux machine which implement a VPN "kill switch" functionality. Essentially you need to create firewall rules which only allow outbound connections through the VPN interface, and to the VPN provider's DNS servers, blocking all other connections.
    – justinjt
    Commented Mar 11, 2020 at 19:19

1 Answer 1


Try this

sudo nano /etc/dnsmasq.conf

My internet is connected via eth0 then theres a vpn connection turned on

interface eth0
static ip_address=  # Static ip for your rpi
static routers=       # your Routers ip
static domain_name_servers= # Dns Cloudfare Server

interface=wlan0       # Use interface wlan0 
server=        # Dns Cloudfare Server
dhcp-range=,,,24h # IP range and lease time

sudo reboot
that should fix the dns leak

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.