Add DNS of Wireguard peer

Ahoy friends.
Currently i got 2 networks connceted using Wireguard, and one of them is using OpenWRT, the client network.
But i want to use the DNS server of the remote network to resolve hostnames, but how can i add the remote dns server in OpenWRT? Unfortunately in the interface setup of the Wireguard setup there is no "DNS" option.
Usually the DNS server is being added inside of the Wireguard config of the client, but in this case it's not possible, because it has been configured using LuCi.
I hope someone could help!

Add another interface, give some name, protocol static, no bridge, interface use the wireguard interface.
Give the IP and mask of your wireguard interface, along with the desired NS. Also assign it in the same firewall zone as the WG interface.
Finally remove the IP and mask from the WG interface, save/commit/apply.

Screenshot_2020-03-30 LPM - DHCP and DNS - LuCI

Defines your subnets domains and dns servers like in my snapshot...
The resolution will become silently and simply available from and through your peer.

1 Like

Thanks!
Unfortunately both ways didn't work.
In case of @trendys way the routes doesn't work anymore.

I've just worked this out as well. At this point I agree with @erdoukki to have the dnsmasq resolver handle it.

Your two LANs must have different domain names, for example a.lan and b.lan. They can't both be lan which is the default.

In /etc/config/dhcp, change options local and domain from the default of lan to a.lan or b.lan. Add a list server '/b.lan/<ip of the b main router>' and list rebind_domain '/b.lan/' to the configuration of a and of course the opposite on b. You will probably have to set localservice to 0 so that the DNS server will answer requests from the other network. That may not be necessary if the VPN tunnel interface is on the same machine where dnsmasq is running, it is not in my case.

If you just want to resolve the remote lan, use the forwarding way.
I understood that you want to use the nameserver of the remote site for everything.

Hello,

I have the same problem. I try to connect the openwrt-router with wireguard to a second network and use the dns of the second network.
The connection to the second network works, but the dns of the connected network isn't used.

I tried both solutions here.

@trendy your solution didn't work at all :frowning: but I think it is the right way
@erdoukki your solution worked to resolve the local addresses, but not for all other domains

I used openwrt 21.02

Maybay I do something wrong, has anyone an idea to bring it to work for me?

kind regards

Have you tried to simply add a forward to the remote DNS IP ? (without /name/)
It will forward all DNS request to the remote DNS server.

1 Like

Yes, I tried it, but didn't change anything. :frowning:

Make sure use DNS forwarding with split DNS.

2 Likes

Screenshot 2021-09-20 at 18-12-02 LPM - DHCP and DNS - LuCI
Yes, as @vgaetera point to, disable also host resolve file

1 Like

Thank you @vgaetera and @erdoukki, that solved my problem.

2 Likes

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