Thursday 1 December 2016

Configuring DNS for an OpenVPN server behind a Virgin Media Hub 3.0

I recently had my old Virgin Media SuperHub replaced with a Hub 3.0. After this, I found that my VPN clients were no longer working. The first thing I needed to do was enable port-forwarding for port 1194 using the Hub 3.0's admin web interface. This was fairly easy to achieve (once I figured out that, for some reason, the admin interface really doesn't like it if you are using a browser in private/incognito mode).

With port-forwarding re-enabled, my VPN clients could connect to the server, but any attempts to access websites would encounter a DNS-resolution failure. To diagnose the issue, I connected to the PI using ssh and then tried using curl to access a website.


    ssh pi@<ip-address-of-pi>
    
    curl https://www.google.co.uk/

This worked fine, proving that DNS lookup worked fine from the PI. After a bit of internet searching, I came across this entry on the OpenVPN forums: https://forums.openvpn.net/viewtopic.php?t=21678. Realising that this explained how the OpenVPN server informs the client what DNS server to use, I had a look at the configuration for my OpenVPN server.


    sudo vi /etc/openvpn/server.conf

Inside this file was the line that had been added when originally setting up the server:


    push "dhcp-option DNS 192.168.0.1"

This is the IP address of the router, so I wondered if this new router was doing DNS differently.

I also realised that my computer was not encountering any DNS issues, so I took a look at its network settings. Sure enough, the DNS server was set to a different address: 194.168.4.100. This address is also the address that was listed under "IPv4 DNS servers" on the Info section of the Admin tab on the router's interface. I therefore updated the line in the server.conf file to use that address.


    push "dhcp-option DNS 194.168.4.100"

With this done, I restarted the OpenVPN server.


    sudo service openvpn restart

Once it was restarted I tried connecting my client again, and voilĂ ! I could now surf the internet again using my VPN connection.