GL-MIFI: Using private DNS server when VPN is up

I have an OpenVPN server to the inside of my own network, and on that inside, I have a DNS server that handles local names. The OpenVPN server actually is on a small rented VPS, and my home’s router servers as an OpenVPN client. The OpenVPN servers uses client-to-client, and its addresses actually are 192.168.6.0/24, while the home route is 192.168.2.0/24 with 192.168.2.1 as the router and the local DNS server.

My GL-MIFI gives out 192.168.8.0/24 addresses and it also makes an OpenVPN connection to the VPS, which therefore serves nicely as a router between 192.168.2.0/24 in my home and 192.168.8.0 for anything connected to the GL-MIFI. This all works. BUT…

How do I make the devices connected to the GL-MIFI understand there is a name server on 192.168.2.1. I tried hard with all sorts of options on the GLMIFI dnsmasq pages, but it doesn’t do it. The devices connected to the GLMIFI are told that 192.168.8.1 is their gateway and DNS, but they can never resolve any of my internal names. /etc/resolv.conf on the GLMIFI is correct (192.168.2.1 and 8.8.8.8 as name servers), and if I ssh to the GLMIFI, I can resolve my internal names.

My workaround was to create an extra hosts file on the GLMIFI with my list of external names; but this means I have to maintain this list in two places, both on my home rounter 192.168.2.1 and on the GLMIFI.

My dnsmasq.conf file is:

auto-generated config file from /etc/config/dhcp

conf-file=/etc/dnsmasq.conf
dhcp-authoritative
strict-order
localise-queries
read-ethers
bogus-priv
expand-hosts
domain=i.engsig.name
server=192.168.2.1
addn-hosts=/etc/hosts.bjorn
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/etc/resolv.bjorn
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
addn-hosts=/tmp/hosts
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq

but this only works with the addn-hosts.

Any ideas?

First, check your ovpn file it it uses IP address rather than dynamic domain name.

If it uses IP address, you can change your MiFi’s custom DNS to your local DNS server in the UI. Don’t change /etc/config/dhcp because there are some places to change for DNS settings.

The only shortback of this is that, when MiFi is not connected to vpn, it may not have Internet.