OpenVPN and DNS resolution for hosts which connected via VPN

Hi Guys,

I have some domain mydomain.com, created a bash script which updates

via api dns entry for home.mydomain.com if my actual IPV4 doesn't match dns.

I also did in /etc/config/dhcp

in dnsmasq

option local '/home.mydomain.com/'

option domain 'home.mydomain.com'

After I exec


sudo openvpn client.ovpn

[sudo] password for myusername:

Sat Oct 2 21:12:26 2021 OpenVPN 2.4.4 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Apr 27 2021

Sat Oct 2 21:12:26 2021 library versions: OpenSSL 1.1.1 11 Sep 2018, LZO 2.08

Sat Oct 2 21:12:26 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]120.225.54.5:443

Sat Oct 2 21:12:26 2021 Attempting to establish TCP connection with [AF_INET]120.225.54.5:443 [nonblock]

Sat Oct 2 21:12:27 2021 TCP connection established with [AF_INET]120.225.54.5:443

Sat Oct 2 21:12:27 2021 TCP_CLIENT link local: (not bound)

Sat Oct 2 21:12:27 2021 TCP_CLIENT link remote: [AF_INET]120.225.54.5:443

Sat Oct 2 21:12:27 2021 [server] Peer Connection Initiated with [AF_INET]120.225.54.5:443

Sat Oct 2 21:12:29 2021 TUN/TAP device tun0 opened

Sat Oct 2 21:12:29 2021 do_ifconfig, tt->did_ifconfig_ipv6_setup=0

Sat Oct 2 21:12:29 2021 /sbin/ip link set dev tun0 up mtu 1500

Sat Oct 2 21:12:29 2021 /sbin/ip addr add dev tun0 192.168.8.2/24 broadcast 192.168.8.255

Sat Oct 2 21:12:29 2021 Initialization Sequence Completed

got connected to home VPN, but DNS are not resolved


myusername@mycomputername:~$ nslookup another-computer.home.mydomain.com

Server: 127.0.0.53

Address: 127.0.0.53#53

** server can't find another-computer.home.mydomain.com: NXDOMAIN

myusername@mycomputername:~$ nslookup another-computer.home.mydomain.com 192.168.8.1

Server: 192.168.8.1

Address: 192.168.8.1#53

Name: another-computer.home.mydomain.com

Address: 192.168.1.9

myusername@mycomputername:~$

I have that in my /etc/openvpn/server.conf


server 192.168.8.0 255.255.255.0

topology subnet

client-to-client

keepalive 10 60

persist-tun

persist-key

push "dhcp-option DNS 192.168.8.1"

push "dhcp-option DOMAIN home.mydomain.com"

Why it is not using 192.168.8.1 as DNS?

I did that

uci set dhcp.@dnsmasq[0].localservice="0"
uci commit dhcp
/etc/init.d/dnsmasq restart

Still not working.

Tried to modify
push "dhcp-option DNS 192.168.8.1"
to
push "dhcp-option DNS 192.168.1.1"
not working

1 Like

Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

cat /etc/config/network
cat /etc/config/dhcp
cat /etc/config/firewall

I'm trying to get 3 files and remove sensitive stuff.

Are you sure that the problem on a server? It works fine this way

myusername@mycomputername:~$ nslookup another-computer.home.mydomain.com 192.168.8.1

Server: 192.168.8.1

Address: 192.168.8.1#53

Name: another-computer.home.mydomain.com

Address: 192.168.1.9

myusername@mycomputername:~$

Curious. Proxy?

This issue is unrelated to OpenWrt since you set up the VPN connection on the client.
Anyway, to make it work, you need to properly integrate the VPN connection with system resolver:

sudo nmcli connection import type openvpn file client.ovpn
sudo nmcli connection up id client
1 Like

@vgaetera you're legend!!!

Many thanks it worked.
Initially I had error: "Error: failed to load VPN plugin: unknown VPN plugin "org.freedesktop.NetworkManager.openvpn"."
Then I found an answer here https://askubuntu.com/questions/760345/cannot-import-saved-openvpn-configuration-file-in-ubuntu-16-04-lts after I installed sudo apt-get install network-manager-openvpn-gnome worked perfectly.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.