Redirect dns request from wan router to OpenWrt dnsmasq

Is there any way to forward dns requests from my wan router to openwrt(lan) which is running dnsmasq dns server?

1 Like

You can set up DNS forwarding on the upstream router, or offer custom DNS with DHCP.
Or specify the downstream router as an exclusive DNS provider for the upstream one.
Another way is to move the DHCP/DNS roles from the upstream router to the downstream.

2 Likes

firewall/routing rule, if there's such an option.

or modify the DHCP settings to point to your DNS instead of the ISPs.

If not possible, disable the DHCP in the router, and use your OpenWRT device as the DHCP,
pointing to itself as DNS, and the main router as default gateway.

Bleh, vgaetera beat me to it :slight_smile:

1 Like

I need to be able to reach hostname provided by openwrt from the devices connected to my main router.

i don't see a/the problem ?

2 Likes

If I put openwrt ip as dns server in the main router than internet stop working.

Disable peer DNS and specify public/ISP resolvers as an upstream provider on OpenWrt:
https://openwrt.org/docs/guide-user/base-system/dhcp_configuration#upstream_dns_provider

Make sure you upstream firewall zone accepts DNS traffic.

If the issue persists, collect the diagnostics and post it to pastebin.com redacting the private parts:

uci show network; uci show dhcp; uci show firewall; \
ip address show; ip route show; ip rule show; iptables-save; \
head -v -n -0 /etc/resolv.* /tmp/resolv.* /tmp/resolv.*/*

I am not able to configure it.
Pastbin link

1 Like

What exactly are you unable to configure?

1 Like

Actually, your OpenWrt config looks correct.
Make sure you specify 192.168.43.2 as the only resolver on the upstream router.

Thank you. Finally the problem is solved.
Actually I was putting 192.168.42.1(openwrt lan ip) on upstream router but after using 192.168.43.2(openwrt client ip), everything is working smoothly.

1 Like

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