This guide addresses common OpenVPN DNS troubleshooting Ubuntu 18.04 issues, where a successful VPN connection does not guarantee proper DNS resolution.
When you use a VPN, your internet traffic, including DNS requests, is routed through the VPN server. DNS requests translate domain names (like google.com) into IP addresses. If your VPN client isn’t configured to use the VPN’s DNS servers, or if there’s a conflict with local DNS settings, you’ll experience a “connected but no internet” problem.
Read: How to Install OpenVPN on Ubuntu 16.04 And 18.04
systemd-resolved ConflictsUbuntu uses systemd-resolved for DNS resolution, which can clash with OpenVPN’s DNS settings. Here’s how to diagnose and resolve this common systemd-resolved conflict resolution Ubuntu issue:
systemd-resolve --status | grep "Current DNS Server" Run this command before and after connecting to your VPN. If it doesn’t show the VPN’s DNS server after connecting, this is likely the source of the problem.
openresolv (Recommended for most users)openresolv manages DNS configurations from multiple sources, including VPNs, and integrates well with systemd-resolved. This is a common approach to achieve Ubuntu OpenVPN DNS configuration fixes. openresolv:sudo apt update
sudo apt install openresolv script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf Explanation:
script-security 2: Permits OpenVPN to execute scripts.up and down: Specify scripts to run when the VPN connection is established and terminated, respectively./etc/openvpn/update-resolv-conf: A script (usually provided by OpenVPN or openresolv) that updates DNS settings based on the VPN connection. It interacts with resolvconf to manage the /etc/resolv.conf file.systemd-resolved (Not Recommended for Long-Term Use)This is a quick test, but *not* recommended for production. It can disrupt services relying on systemd-resolved. systemd-resolved:sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved /etc/resolv.conf:sudo nano /etc/resolv.conf nameserver 10.8.0.1
nameserver 8.8.8.8 # Optional: Fallback public DNS (Google DNS) /etc/resolv.conf and re-enable systemd-resolved:sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved Even with DNS routed through the VPN, leaks (DNS requests going through your ISP) can occur. Enforce stricter DNS settings to prevent this:
block-outside-dns
dhcp-option DNS For example, to add to your .ovpn file:
sudo nano /etc/openvpn/client.ovpn Then add (replace 1.1.1.1 with your VPN’s DNS server):
dhcp-option DNS 1.1.1.1 block-outside-dns: (Primarily for Windows) Prevents DNS leaks.dhcp-option DNS: Explicitly sets the DNS server, overriding local network settings.Rarely, your firewall (ufw) might block DNS traffic (port 53, UDP and TCP, usually UDP):
sudo ufw allow out 53 For restrictive firewalls, create specific rules allowing traffic to/from your VPN’s DNS server IP.
Check the status of the openvpn service and the syslog to find valuable information:
sudo systemctl status openvpn sudo tail -f /var/log/syslog | grep openvpn Read: How to set up a UFW on Ubuntu 22.04
sudo systemctl restart openvpn@service_identifier (Replace service_identifier with your actual service name, if applicable. If you are not using a systemd service, you can omit the `@` and what follows).
sudo service openvpn restart dig: dig google.com Output should show google.com’s IP and the DNS server used (should be your VPN’s).
nslookup: nslookup google.com The nslookup command queries the DNS to obtain domain name or IP address mapping.
.ovpn, /etc/resolv.conf).DNS resolution problems with OpenVPN on Ubuntu 18.04 are often caused by conflicts with `systemd-resolved`, DNS leaks, or firewall issues. The most reliable long-term solution is typically using `openresolv` and correctly configuring your OpenVPN client. Always remember to restart the OpenVPN service after making configuration changes, and use online tools to verify your IP address and DNS server.
The post Fixing OpenVPN DNS Issues on Ubuntu 18.04 appeared first on net2.
Canonical announces that the Advantech AOM-2721 is officially joining the list of Ubuntu Certified Hardware.…
Yet again instead of tweets, a blog post. The backlog got out of hand -…
This article provides a guide demonstrating how to deploy OpenProject on Ubuntu VPS. What is…
Canonical is pleased to announce that NVIDIA’s newly introduced NVIDIA Nemotron 3.5 Lightning, an open,…
If you have been using an ecommerce store to place online orders or have been…