Android模拟器-dns服务器用法 [英] Android emulator -dns-server usage

查看:262
本文介绍了Android模拟器-dns服务器用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有点挣扎着爬了Android模拟器使用自定义的DNS服务器,它运行在localhost(127.0.0.1)。

I am currently somewhat struggling to get the Android emulator to use a custom DNS server, which is running on localhost (127.0.0.1).

截至目前,我已经试过各种方法试图说服模拟器使用我的DNS服务器,但至今没有成功。最后,它总是归结为以下错误信息:

As of now, I have tried various approaches trying to convince the emulator to use my DNS server, so far without success. In the end, it always boils down to the following error message:

### WARNING: can't resolve DNS server name 'localhost'
### WARNING: will use system default DNS server

本地主机,然而,解决正确时提供与nslookup:

localhost, however, resolves correctly when supplied to nslookup:

$ nslookup localhost
Server:  dnszrh01.xxx
Address:  10.xxx.xxx.xxx

Non-authoritative answer:
Name:    localhost.xxx
Address:  127.0.0.1

使用的IP地址而不是主机名,也没有太大的帮助, 它只是改变了错误消息:

Using the IP address instead of the hostname also does not help much, it just changes the error message to:

### WARNING: can't resolve DNS server name '127.0.0.1'
### WARNING: will use system default DNS server

我用来启动模拟器额外读取命令行:

The extra command line I am using to start the emulator reads:

-http-proxy http://proxy.xxx:8080 -dns-server 127.0.0.1 -debug-proxy -verbose

这是发生了Android模拟器版本5.0(build_id ECLAIR-24846)在Windows上运行。

This is happening with Android emulator version 5.0 (build_id ECLAIR-24846) running on Windows.

任何提示如何得到这个工作是非常AP preciated!

Any hint how to get this working is much appreciated!

推荐答案

一对夫妇的事情...

A couple things...

1)我发现我得到这个错误还当我有没有网络连接的。 IE浏览器。没有无线或以太网连接。

1) I've noticed I get this error also when I have no network connectivity at all. ie. No wireless or ethernet connection.

2)摘自模拟器指南: <一href="http://developer.android.com/guide/developing/tools/emulator.html#dns">http://developer.android.com/guide/developing/tools/emulator.html#dns

2) Excerpt from Emulator guide: http://developer.android.com/guide/developing/tools/emulator.html#dns

配置仿真器的DNS设置   在启动时,仿真器将读取你的系统当前正在使用的DNS服务器列表。然后将其存储的列表上多达四个服务器的IP地址,并设置别名他们在仿真地址10.0.2.3,10.0.2.4,10.0.2.5和10.0.2.6根据需要

Configuring the Emulator's DNS Settings 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.

在Linux和OS X中,模拟器通过解析文件/etc/resolv.conf获得DNS服务器地址。在Windows中,模拟器通过调用GetNetworkParams()API获取地址。请注意,这通常意味着模拟器忽略文件在您的主机的内容(在Windows上的/ etc /在Linux / OS X主机,%WINDOWS%/ SYSTEM32 /主机)。

On Linux and OS X, the emulator obtains the DNS server addresses by parsing the file /etc/resolv.conf. On Windows, the emulator obtains the addresses by calling the GetNetworkParams() API. Note that this usually means that the emulator ignores the content of your "hosts" file (/etc/hosts on Linux/OS X, %WINDOWS%/system32/HOSTS on Windows).

在启动仿真器在命令行中,您还可以使用-dns服务器选项来手动指定DNS服务器的地址来使用,在这里是逗号分隔的服务器名称或IP地址的列表。有用的,如果你遇到的模拟网络中的DNS解析问题(例如,使用Web浏览器时,会出​​现未知主机错误的信息),你可能会发现这个选项。

When starting the emulator at the command line, you can also use the -dns-server option to manually specify the addresses of DNS servers to use, where is a comma-separated list of server names or IP addresses. You might find this option useful if you encounter DNS resolution problems in the emulated network (for example, an "Unknown Host error" message that appears when using the web browser).

3)另见本其他的StackOverflow问题: <一href="http://stackoverflow.com/questions/3468712/android-emulator-doesnt-use-windows-host-file">Android仿真器不使用Windows主机文件?

3) Also see this other StackOverflow question: Android emulator doesn't use Windows host file?

这篇关于Android模拟器-dns服务器用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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