Hello!
I am quite a newbie in Nftables/Dnsmasq and have a question: when does Dnsmasq (Dnsmasq-full to be precise) fills Nft IP Sets and is there a way to rigger it to re-populate a set?
A bit more details. Let's assume I have a Firewall IP Set (Nft Set) which is used in a Firewall Rule to mark traffic. The marked traffic then will be re-routed to another interface using Routing Table + Routing Rule.
The IP Set looks like this (below is a part of the /etc/config/firewall file):
config ipset
option name 'reroute_test'
option family 'ipv4'
list match 'dest_net'
And I have a Dnsmasq IP Set (Rule?) to populate the Nft Set with values (below is a part of the /etc/config/dhcp file):
config ipset
list name 'reroute_test'
option table_family 'inet'
list domain 'ifconfig.io'
list domain 'myip.com'
When I apply this config and run nft list set inet fw4 reroute_test
command I see an empty Nft Set:
table inet fw4 {
set reroute_test {
type ipv4_addr
flags interval
auto-merge
}
}
If the Nft Set is empty the traffic is routed via default wan interface (I can check this by visiting myip.com or ifconfig.io - they both show the default wan interface IP address).
After a while however it gets some values:
table inet fw4 {
set reroute_test {
type ipv4_addr
flags interval
auto-merge
elements = { 104.21.92.106, 104.26.8.59,
104.26.9.59, 172.67.75.163,
172.67.191.233 }
}
}
And of course now the traffic flows through another wan interface (both myip.com and ifconfig.io show another IP address).
If I flush the Nft Set: nft flush set inet fw4 reroute_test
it will remain empty for a while.
So my question is what exactly triggers Dnsmasq to fill the Nft Set and how can I manually trigger to do it or at least set a shorter interval?
If I change the Dnsmasq IP Set (Rule) and delete/add a few hosts, I'd like them to be resolved into the Nft Set as soon as possible. As an alternative I can write a script: something like this:
nft flush set inet fw4 reroute_test
<command to trigger Dnsmasq to re-populate the Set>
And run it each time I change the Dnsmasq IP Set.
Thank you in advance for any help and advice!
UPD: Forgot to mention that the real host list will consist of hosts which change their IP frequently thus I need to flush and re-populate the Nft Set frequently. Also the list itself (i.e. host names) changes frequently: some hosts are being added, some are being removed.