Restricting OpenVPN connection to only one program

My Linux server works with YouTube videos a lot, downloading and collecting data about them with the help of youtube-dl.

I want to route this program (youtube-dl) through an OpenVPN connection. Seems simple enough, except I need only youtube-dl to use the VPN connection, as I also run a web server among other things which cannot use the VPN connection.

How can I configure my server to only use the OpenVPN connection for youtube-dl?

Without a separate VM.


I forgot I asked this question, but I may as well leave the solution I ended up using here:

You can use a program called Vopono that works by creating temporary network namespaces.

It supports the Wireguard, OpenVPN, OpenConnect and OpenFortiVPN protocols, and can also be used out-of-the-box directly with many VPNs such as PIA and NordVPN as well, if that suits your needs.

Example usage with an OpenVPN configuration file:

vopono exec --custom vpn_config.ovpn --protocol openvpn "youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ"

No VM or anything like that needed!

More detailed usage info can be found here.