Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I would like to direct all the traffic through my VPN connection on my Android based phone (HTC Desire). The VPN works great, but problem is that when the VPN disconnects, the traffic is redirected through my regular internet, something I don't want to happen. How can I block the traffic outside the VPN?

share|improve this question
    
using Tasker(app), I can put the phone into flight mode when an event occurs, in this case a message notification at the top bar. This does occur when the VPN disconnects, however the program can't distinguish that from any other message. What I need is a standalone app that would pop a message when the VPN disconnects. Do you know any? –  Betty Kantor Oct 11 '11 at 18:17
    
Flight mode also disables the cell radio, are you sure that you wish to disable calling features too when disconnected from the VPN? –  onik Oct 11 '11 at 20:29

1 Answer 1

You could use DroidWall for this IF you're rooted. Just deny all traffic and then allow traffic to your VPN IP/port. If you need to use a custom script see the man page of iptables for the syntax. Here's a quick, untested example.

iptables -P FORWARD ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -A OUTPUT -p udp --dport 1194 -d xxx.xxx.xxx.xxx -j ACCEPT
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.