Been searching for the answer, but have found nothing.
Like most smart Internet users, I use a VPN. You can correct me if I'm wrong, but when I set up a VPN (using the OpenVPN protocol, at least) the network routing looks like this:
app 1 ----- | app 2 -----+ ----- tun0 -----> outside world | app 3------+
Then, if the vpn is shut down:
app 1 ----- | app 2 -----+ -----------> outside world [No protection :(] | app 3------+
The issue I've come across in spending hours on this problem is that I was able to get this to work (allowing only tun0 to anywhere) but only if tun0 was already active, and only during that connection session. Once I ended the connection the rules would not allow any traffic through, and wouldn't even connect to the vpn.
Strangely, Android makes this very easy. All I need to do is install AFWall+, my favorite VPN, allow connections to the net to my VPN, and then allow only VPN connections from apps I want. All others will be blocked, and if the VPN goes down, no traffic will be allowed through. Why is this so hard to do on a PC?
tl;dr Is there a ufw rule to allow all/some traffic to tun0, then allow traffic from tun0 to anywhere?