Redirect certain domains to VPN

Hello,

I need to access some sites through VPN. I can more or less understand how to set it up using IP addresses, but the problem is that some sites have pools of addresses, and I don’t always know them in advance.

I could, of course, create static DNS entries, but I just thought that maybe it is possible to have a script that would dynamically do what I need? Preferably using a list in a text file.

If there is no ready script, I would appreciate some directions on where to look.

Thanks in advance!