Skip to content
Contents
GuidesOpenWrt

How to put one domain in two IPv4 sets on OpenWrt

If two policies share only a few domains, give those names a mapping with both destination sets. Keep the remaining domains in their own rules.

If two policies share only a few domains, give those names a mapping with both destination sets. Keep the remaining domains in their own rules.

Check the same A record in both sets

In an isolated OpenWrt 25.12.6 x86/64 VM, dnsmasq-full 2.93 got both address families from a local upstream. Both sets here take IPv4, so follow 192.0.2.42. With separate sections for the same domain only sites4 received it in this serial log. If both sets already update, leave them alone.

OpenWrt 25.12.6 · dnsmasq 2.93 · 2 × config ipset
OpenWrt 25.12.6 · dnsmasq 2.93 · 2 × config ipset

List both names in one section

Over SSH check for nftset support. Both sets must exist with type ipv4_addr. Create missing sets in persistent firewall settings first. Replace gm with your table name, often fw4.

dnsmasq --version
nft list sets
nft list set inet gm sites4
nft list set inet gm media4

Back up /etc/config/dhcp. Move the shared domain out of both old mappings into the section below. Replace dual.test with your test domain. Both runs kept family at 4.

config ipset
    list name 'sites4'
    list name 'media4'
    list domain 'dual.test'
    option table 'gm'
    option table_family 'inet'
    option family '4'

Restarting briefly interrupts DNS. Check the active instance’s configuration. Both targets with a 4 prefix should share a line, as in the output below.

/etc/init.d/dnsmasq restart
grep '^nftset=' /var/etc/dnsmasq.conf.*
nftset=/dual.test/4#inet#gm#sites4,4#inet#gm#media4

Check both lists with a fresh answer

On the router query an uncached name whose address is absent from both sets. Leave production sets intact. After grouping the targets, the same IPv4 address appeared in both elements lists.

nslookup dual.test 127.0.0.1
nft list set inet gm sites4
nft list set inet gm media4
OpenWrt 25.12.6 · dnsmasq 2.93 · 1 × config ipset
OpenWrt 25.12.6 · dnsmasq 2.93 · 1 × config ipset

If only one fills, check types, the responding instance and more specific domain mappings. If entries vanish after a firewall reload, check when sets are recreated. On failure restore the backup and restart dnsmasq. Verify each policy’s actual route separately. For mixed address families see the dual-stack example below.

OpenWrt table_family explained when only the IPv4 set fills

Explore hardware

Comments