模拟器网络IP地址和虚拟路由器 [英] Emulator networking ip address and virtual router

查看:323
本文介绍了模拟器网络IP地址和虚拟路由器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows上使用android模拟器. android开发人员文档说,模拟器的每个实例都在虚拟路由器/防火墙服务之后运行.每个实例的虚拟路由器管理10.0.2/24网络地址空间.但是,当我使用adb shell连接到仿真器并执行ifconfig时,得到以下输出:

I am using android emulator on windows. The android developer doc says that each instance of the emulator runs behind a virtual router/firewall service. The virtual router for each instance manages the 10.0.2/24 network address space . However, when I connect to the emulator with adb shell and do ifconfig, I got the following output:

radio0链接封套:UNSPEC inet地址:192.168.200.2广播:192.168.200.255掩码:255.255.255.0

radio0 Link encap:UNSPEC inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0

wlan0 Link encap:UNSPEC inet地址:192.168.232.2广播:192.168.239.255掩码:255.255.248.0

wlan0 Link encap:UNSPEC inet addr:192.168.232.2 Bcast:192.168.239.255 Mask:255.255.248.0

ip route show给我下面的输出

192.168.200.0/24 dev radio0原始内核作用域链接src 192.168.200.2

192.168.200.0/24 dev radio0 proto kernel scope link src 192.168.200.2

192.168.232.0/21 dev wlan0原始内核作用域链接src 192.168.232.2

192.168.232.0/21 dev wlan0 proto kernel scope link src 192.168.232.2

我看不到任何10.2.x.x ip地址.这些IP地址在哪里?

I do not see any of the 10.2.x.x ip address. Where are those ip address?

虚拟路由器是否也在模拟器中运行(在Android OS上)还是在Windows上运行?如何检查虚拟路由器?

Also does the virtual router run within the emulator (on the Android OS) or run on windows? How to exam the virtual router?

推荐答案

我在Windows上运行Android 7.1.1(API 25)时遇到了同样的问题. 但是,当我模拟Android 7.0(API 24)时,它可以按预期工作.设备获得IP 10.0.2.15.在这种情况下,ip route show将带来10.2.x.x地址.因此,如果您只能使用早期版本(API 16-API 24).

I have the same issue running Android 7.1.1 (API 25) on Windows. But when I emulating Android 7.0 (API 24) it works as expected. Device gets IP 10.0.2.15. In this case ip route show will bring 10.2.x.x address. So, if you can just use prior versions (API 16 - API 24).

此路由器存在于模拟器中,Windows对此不了解. 如果需要从Windows访问在模拟器中运行的服务,则需要添加端口映射:

This router exists inside emulator and Windows is not aware about it. If you need to access service running inside emulator from Windows, you need to add port mappings:

telnet localhost 5554
auth <token from 'C:\Users\{user}\.emulator_console_auth_token'>
redir add tcp:8080:8080

然后,您可以通过以下方式访问服务:127.0.0.1:8080.但是,这种方法不适用于Android 7.1.1.我不知道这是怎么回事.

Then you can access your service by: 127.0.0.1:8080. However, this approach does not work with Android 7.1.1. I have no ideas what is wrong with it.

这篇关于模拟器网络IP地址和虚拟路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆