Pi-hole over openVPN connection


In short, I want all devices that connect via VPN to use my pi-hole as DNS.

I know there is already an article that deals with this topic.

Unfortunately I don’t speak the language and I don’t know if the constellation is the same as mine.

Let’s start…

I have already installed an active openVPN service via Foris. It works fine. I have configured the firewall that all devices that connect to the VPN can access all devices in the “normal” network.

The pi-hole runs as LXC container on the router.
the pi-hole is configured as DNS server in DHCP.
All devices in the “normal” network get it assigned as DNS by DHCP.

How do I configure that all VPN connections get the pi-hole as DNS server?

Yes, I think your constellation is the same (I’m native CZ). The critical part seems

 list push 'dhcp-option DNS’

in /etc/config/openvpn (on the VPN server). I mainly skimmed the CZ topic; I don’t really have first-hand knowledge.

Oh, wait, that seems weird to me. Anyway, he used a firewall rule to let the address through, but I’m really confused from the approach. Perhaps it’s best to ignore me on this thread and hope someone else knows better :slight_smile:


I think that for the working state you need two things:

  1. Firewall rule for comunnication from VPN to DHCP server (accept) = accept communication from VPN network to IP of your pi-hole “machine”, you can add any (tcp/udp) or just 53 TCP/UDP (DNS). It’s possible that something like that already exists after the creating the VPN (because you want to comunicate to your local network remotely so there should be rule for the comunication from VPN network to LAN, the problem is if you have pi-hole in some special network for example - in that case you will need to create the rule for accepting the comunication, but if you have that pi-hole server in - native LAN - you don’t need that rule, it should exist)
  2. That setting saying that the DHCP server is IP with pi-hole

That guy said that you must edit file /etc/config/openvpn and there should be something like:
config openvpn 'server_turris’
option enabled '1’
option port '1194’
option proto 'udp’
option dev 'tun_turris’
option ca '/etc/ssl/ca/openvpn/ca.crt’
option crl_verify '/etc/ssl/ca/openvpn/ca.crl’
option cert '/etc/ssl/ca/openvpn/01.crt’
option key '/etc/ssl/ca/openvpn/01.key’
option dh '/etc/dhparam/dh-default.pem’
option server '’
option ifconfig_pool_persist '/tmp/ipp.txt’
option duplicate_cn '0’
option keepalive '10 120’
option comp_lzo 'yes’
option persist_key '1’
option persist_tun '1’
option status '/tmp/openvpn-status.log’
option verb '3’
option mute '20’
list push 'route’
list push 'redirect-gateway def1’
list push 'dhcp-option DNS’
list push ‘dhcp-option DNS’

The bold text is the parameter which says that the DNS server is on the specific address. You should change the addres to your situation. You must have the address od your pi-hole server before the default address (in this example because you want pi-hole to be the primary DNS server otherwise the default DNS will work as the primary DNS and you don’t want that.

I’m not sure for what purpose those italic lines have so it’s possible that you will have some different values (it’s possible that even the address of default DNS will be different - that’s OK).

1 Like

Thanks for the answer.

I have tested it and it works.

I only modified the config /etc/config/openvpn with “list push ‘dhcp-option DNS’”. is my pi-hole.

After a restart it worked immediately.

Thanks a lot!

1 Like