Doing this programmatically how about
GitHub - schwabe/ics-openvpn: OpenVPN for Android[
^] and a openVPN server. There are several cheap routers that come with a openVPN server including the instruction to set it up on android. Remember, you will need a static ip or dynamic ip services and some port-forwarding-configuration - a lot of pitfalls. The config for openVPN should be the same for this lib. Btw, entering the credentials (VPN profile available since KitKat) in settings > wireless and networks > vpn and 0.0.0.0/0 as forwarding route will forward ALL traffic with no further effort. But, as far as i know, that requires you to connect manually each time. that's it.
take care and report back...