How can I get my android emulator use my computer's VPN interface?
Asked Answered
F

6

79

My company requires VPN to connect to our dev systems and for the first time I'm trying to work on an android app from home. Turns out the emulator doesn't want to use the VPN interface so even though I have connectivity to our dev systems on my VPN-connected laptop the emulator that's running on it does not.

I have thought of 3 solutions to this:

  1. run a VPN client on the emulator, but I was hoping for a simpler solution than that
  2. setting up a proxy server on my local machine
  3. forwarding a port on my local machine

2 and 3 can probably work, but I'd still like to know if there is an easy way to get the emulator to use the VPN interface without a workaround.

I'm running OS X 10.7 and I've already tried adjusting the interface priority order with network>>set service order.

I suppose I can dust off the old dell and try it there, but I would expect the same results.

Frequentative answered 4/8, 2011 at 14:24 Comment(3)
May depend upon your VPN, some alter the network drivers or add their own security (MAC based) around allowing devices access to the VPN tunnel.Schwenk
As an FYI on this since its been awhile, I didn't end up getting it to work so I can't really accept the answer because it didn't work for me. If this works for anyone else, be sure to upvote the answer.Frequentative
Hi, I came here to find out if anyone has a different solution. I tried using the solutions present in this discussion but none have worked for me. Thanks.Tip
M
104

First start your vpn connection and then restart the emulator, now the emulator should use the host vpn connection.

it's mostly because of the DNS issue, according to the android doc:

At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed.

Mortimer answered 10/5, 2013 at 8:56 Comment(0)
S
22

enter image description here

I encountered this issue and tried something on dns settings but I could not solve it. As @machado said in the comment section below you should boot the emulator via "Cold Boot Now" option. I hope this helps.

Sharpwitted answered 7/7, 2020 at 12:50 Comment(4)
Wiping data is not needed, you can workaround by starting the VPN and then "Cold Boot Now" the device.Meridel
@Meridel answer is the correct solution. wipe data doesnt work.Zoara
Ok, maybe you ran into a different scenario, for me and at least other five people it did work. Thanks for sharing your thoughts.Meridel
The only thing I did was the "Cold boot now" as Machado said, and it worked.Airdry
P
9

What I do on my mac is just make sure 'send all traffic over vpn' is checked. You'll find this setting after you click advanced while having your vpn connection selected in network preferences.

Works well for my situation, but may not depending on the type of VPN you're connecting to.

VPN Advanced Settings

Placida answered 8/9, 2011 at 19:46 Comment(4)
This was the clue that solved my problem, though it required more research to find out how to do the same thing using Tunnleblick: VPN Details->Configurations[my_company_config]->Settings->Advanced->While Connected then check "Route all traffic through the VPN.Freeboard
Any idea where an option like this would show up for the Cisco AnyConnect VPN on Mac? I don't see a VPN connection in network preferences, and I can't find an option like this directly in AnyConnect.Eudo
I don't know if this is an option for AnyConnect on OS X. I try to never use a client-specific vpn on OS X these days for fear of updates to the OS X completely hosing my vpn, so I usually stick to IPSec or VPN solutions that support openvpn clients (like newer barracudas). Depending on how locked down your vpn is, you may be able to add a route to help you along. More info here: apple.stackexchange.com/questions/144572/… and here: tim.rideyourbike.org/2013/02/…Placida
Worked, but looking for better solution. Does anyone know how to make it use the VPN with out sending all traffic? My Client's VPN is locked down and I cant use any external internet at all when connected to the VPN and sending all traffic. This means I have to be connected and disconnecting all the time for google and to ping people.Preclude
M
6

I had the same issue and solved it by connecting to cisco vpn after the android emulator has started and connected to the internet.

Works for me in windows 7

Monique answered 17/10, 2012 at 14:34 Comment(1)
Unfortunately this didn't work for me.. also using Cisco VPN and Win7Sweeny
B
3

I setup a vpn connection on Windows. Then I started the emulator. The emulator and everything on my pc started to use that vpn connection.

Bonnibelle answered 10/9, 2013 at 15:52 Comment(0)
J
2

The solution depends on your environment, for me: win10+V2ray(VPN client)+android studio.

The solution works:

  1. start the emulator
  2. open the emulator's settings(not the phone's setting)
  3. settings->proxy->manual
  4. set host:127.0.0.1, port:1081

I found enter image description here this at the bottom of the V2ray.

I suppose the default port for HTTP is 1081, and socks is 1080, so I tried both. And here 1081 works.

If you use another VPN client, try to replace your port, and it may work.

Janusfaced answered 14/7, 2023 at 2:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.