I would like to access a web service provided by one of the machines on my LAN from the android emulator.
If the service was running on the same machine where the emulator is running (called host), I could add a network redirection and access the 10.0.2.2 (host loopback interface in the emulator) with the correct port.
However it is running on another machine on the LAN. I guess I could add another redirection on the host additionally to the above one (would have to fight with iptables though ... ), but does a more simple solution exist ?
Well, it just works (TM).
In the android emulator manual that I had read before testing (I try to RTFM before doing things) this is stated:
Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet to a router/firewall.
This made me think that it could not access my LAN. I was wrong, just adding the IP of the server on my LAN allowed me to access it from the emulator.
As we know, emulator can access host machine by IP 10.0.2.2, so I tried IP forwarding but I could not make it working.. :|
I followed link below for forwarding request from localhost(10.0.2.2 in case of emulator) to the other machine in LAN.
http://www.debuntu.org/how-to-redirecting-network-traffic-a-new-ip-using-iptables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With