Run a command when a particular hostname is resolved

Hi,

I would like to route certain traffic via my VPN, however the destination IPs are not static. I just know the hostnames. I am currently just manually updating iptables with the ip address whenever they change, but thats cumbersome even though I have written myself a little update script. I would like to automate this - is it possible to run an external script (with hostname, ip address/ CNAME) whenever an ip is resolved?

That way I could filter the hostname in the script, and update my iptables if necessary. Alternatively filtering in pi-hole would be easier of course (i.e. a nice graphical interface to define the hostnames), but I think that might be harder.

Any suggestions on how to achieve this would be welcome!

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