のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

Android EmulatorのIPアドレス。

getpropの値
[net.dns1]: [10.0.2.3]
[net.dnschange]: [1]
[net.eth0.dns1]: [10.0.2.3]
[net.eth0.gw]: [10.0.2.2]
[net.gprs.local-ip]: [10.0.2.15]

  • 10.0.2.2へpingしたら、返ってきた。
  • 192.168.1.1へpingしたら、返ってこなかった。
  • hatena.ne.jpをDNSで引いたら、返ってきた。

IPアドレス 概略
10.0.2.1 ルータ/ゲートウェイアドレス
10.0.2.2 エミュレータが起動しているPCを指すlPアドレス
10.0.2.3 DNS サーバ
10.0.2.4/10.0.2.5/10.0.2.6 セカンドDNSサーバ、サードDNSサーバ…
10.0.2.7 エミュレータデバイスのethernet interface
127.0.0.1 エミュレータのloopback

これらはAndroid Emulator | Android Developersに書かれている。

Emulator Networking

The emulator provides versatile networking capabilities that you can use to set up complex modeling and testing environments for your application. The sections below introduce the emulator's network architecture and capabilities.
Network Address Space

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.

The virtual router for each instance manages the 10.0.2/24 network address space ? all addresses managed by the router are in the form of 10.0.2.<xx>, where <xx> is a number. Addresses within this space are pre-allocated by the emulator/router as follows:
Network Address Description
10.0.2.1 Router/gateway address
10.0.2.2 Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)
10.0.2.3 First DNS server
10.0.2.4 / 10.0.2.5 / 10.0.2.6 Optional second, third and fourth DNS server (if any)
10.0.2.15 The emulated device's own network/ethernet interface
127.0.0.1 The emulated device's own loopback interface