12

I have two questions concerning the VpnService.Builder class.

Suppose I know an App communicate with its server www.somedomain.com, I know the server's IP address is 210.32.204.165.

  1. About the addAddress(String address, int prefixLength) function. In documentation, it says this function "add a network address to the VPN interface", what does that mean? Does it mean the traffic goes to that address (server IP address of an App) will go through VPN or traffic from this address (device IP?) will go through VPN?

  2. There is a function addAllowedApplication(String packageName) which specify which app's traffic go through the VPN tunnel. Is there a way or a function to force all traffic send to server www.somedomain.com go through VPN tunnel?

Leem.fin
  • 40,781
  • 83
  • 202
  • 354

2 Answers2

1
  1. It mean the traffic goes to that address (server IP address of an App) will go through VPN

  2. link: if this method is never called then all applications are allowed by default. If some applications are added, other, un-added applications will use networking as if the VPN wasn't running. So you can to never call this method and all applications will use VPN

MaxV
  • 2,601
  • 3
  • 18
  • 25
  • Hi, thanks for the answer, however, your 2nd answer doesn't answer my question, I mean I know that I can route a specific app's traffic through VPN, by using addAllowedApplication(...), but my question is whether there is a way to route the traffic to a specific host e.g. www.myhost.com to VPN? – Leem.fin Feb 16 '17 at 13:41
  • So you should use "addAddress" to add www.myhost.com and do **not** set any application. After that all traffic to www.myhost.com will go throw VPN. – MaxV Feb 17 '17 at 18:23
0

I haven't test the feature but, NetGuard application has port forwarding feature.

This application act as firewall for route the other application traffic through VPN.

Its a open source project. you can find it on github.

Jarvis
  • 1,714
  • 2
  • 20
  • 35
  • thanks, but like I said,I know how to route app's traffic through VPN, my question is how to route a traffic to a specific hostname through VPN. – Leem.fin Feb 17 '17 at 12:20