I need to apply an nftables rule to all traffic originating from a specific host, but the packets will not necessarily include the proper FQDN, so I need to rely on the IP address(s). The issue is that there are multiple redundant IP's returned for the FQDN that may change order/priority from time to time, or may even be replace entirely.
Because there are multiple IP's returned, I have to use a mutable named set, but I need that set to update somewhat regularly to ensure we have an up to date list of IP's to match against.
We have BIND9 (named) on the server so my thought is that I could have a cron job script that:
- Flush the local dns resolver for the the FQDN with
rdnc flushname..., - Then dig against it to update the resolver cache with
dig +short..., - Run
nft add element...with the new ones, - Flush the old named set with
nft delete element...
Is this the right way to go about this, or have I overthought something thats already been solved another way?