I would like to block specific apps from making connection to internet. I sometimes am connected by VPN but not always. How can I make firewall work for both VPN and not VPN, wifi and mobile data? My phone has root.
Android permits only one VPN to be working on the phone and that is the problem since firewalls also usually create a VPN and you are forced to switch off the VPN to make the firewall work.
However, there is a workaround, at least in some cases. I use Adguard which is an Adblocker with an integrated firewall. It creates it's own VPN on the device locally to filter ads. I also use Keep Solid VPN which is set to always use in my settings (Pie) . Adguard has a proxy mode which permits both VPNs to be used and since your device is rooted, it is easier.
However, note :
All VPNs may not work in this fashion. Check the Adguard forums.
In proxy mode, the efficacy of Adguard firewall is reduced but in my case I have no problems in blocking internet access to apps.
If I want only the Firewall functions but not Keep Solid VPN, I simply disconnect it from the notification panel.
To sum up, it's possible but you need to invest time in checking and ensuring both work.