Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Unable to connect to VPN server via ToyVpn app; getting port unreachable exception

Tags:

android

vpn

I am trying to create a VPN client on android. I looked at android sample application "ToyVpn", I tried to connect to my PC( Windows 7) from this app but I'm getting port unreachable exception.

E/ToyVpnService(2302): Got java.net.PortUnreachableException: 
E/ToyVpnService(2302): Got java.net.SocketException: sendto failed: ECONNREFUSED (Connection refused)

But when I connect to my PC via default vpn client of Android then it connects successfully. And by typing "netstat" in command line I observed that my pc's port 1723 is connected to phone's port 36302. So, offcourse port is reachable.

It is sample application, it should work...But I saw someother links too which mentioned that they are unable to connect to server via this app.

Does this sample work at all? Does this API needs rooted phone?

Except for this I did not find any sample or tutorial to show proper use of "android.net.VpnService".

Can any one please guide me about this..?

like image 575
blackfyre Avatar asked Nov 02 '12 13:11

blackfyre


1 Answers

ToyVpnService is a sample implementation of a simple custom VPN. It is not standards compliant. If you want a standards compliant VPN you should use the built in one.

If you want to test the sample there is a linux server that understands the ToyVPN protocol that is packaged with ToyVPN example.

https://github.com/android/platform_development/tree/master/samples/ToyVpn

It is called ToyVPN because it is just that.

  • It does no encryption
  • It does no mutuale authentication
  • It sends the pre-shared authentication key in plain text
  • It does not gracefully handle unexpected packets
  • It does not guarentee the integrity or origin of packets

It only shows how the VpnService API can capture packets from application on the phone destined for the internet and push them down a tunnel. Similarly, how to inject packets into application as though they came from the network.

The rest is upto the developer to implement.

like image 117
OwainD Avatar answered Sep 23 '22 03:09

OwainD