Hi all,

I'm working on an embedded Linux router setup and had a question regarding how 
dnsmasq selects the outbound interface for upstream DNS queries.

In my use case, I have:
    • ether1 providing LAN access with DHCP/DNS via dnsmasq
    • wwan0 (LTE) as the primary WAN uplink
    • ether0 configured as a fallback WAN

I’ve set up policy routing to ensure traffic originating from ether1's IP goes 
out via wwan0. Here's a simplified view:

Default kernel routing table:
# ip r
default via 172.16.99.1 dev ether0 proto dhcp src 172.16.99.2 metric 30 
default via 28.21.173.0 dev wwan0 proto static metric 50 
default via 172.16.0.254 dev ether1 proto static metric 998 

Custom routing table (natlan) with policy rule:
# ip r s t natlan
default via 28.21.173.0 dev wwan0

# ip rule
0:      from all lookup local
32764:  from 192.0.2.2 lookup natlan
32765:  from all iif ether1 lookup natlan
32766:  from all lookup main
32767:  from all lookup default

This works fine for general traffic, but I want to ensure that dnsmasq itself 
sends its upstream DNS queries via wwan0, not ether0 (which it currently does 
because of the lower metric in the default route).

Question:
Is it possible for dnsmasq to honor policy routing (e.g., via ip rule) for 
outbound DNS queries, or to bind its source IP explicitly so Linux routing 
decisions follow the correct table?

Has anyone implemented something similar where dnsmasq's traffic uses a 
specific interface or follows a source-based policy route?

Any help or examples would be greatly appreciated!

Cheers,
Nitesh
_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss

Reply via email to