I want to find IP Address
of device through their hostname
in local network. Lots of applications in market do this. It gives both IP Address
and hostname
, like Fing
, IP Tools
and many more. But still I am unable to find IP Address
from hostname
.
I am able to find IP
of hostname
by using dig
, arp
and ping
command in ubuntu OS 14.04
see following command:
dig @224.0.0.251 -p 5353 example.local
This command gives me output like this :
; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> @224.0.0.251 -p 5353 example.local
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56566
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.local. IN A
;; ANSWER SECTION:
example.local. 10 IN A 192.168.0.142
;; Query time: 0 msec
;; SERVER: 192.168.0.142#5353(224.0.0.251)
;; WHEN: Mon May 30 17:01:06 IST 2016
;; MSG SIZE rcvd: 47
That specific ANSWER SECTION
gives me ip
against hostname
.
also when I used following command :
arp -vn example.local
It gives me following output:
Entries: 4 Skipped: 4 Found: 0
example.local (192.168.0.142) -- no entry
Also when i ping device with their hostname
ping example.local
It also gives me IP Address
:
PING example.local (192.168.0.142) 56(84) bytes of data.
64 bytes from 192.168.0.142: icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from 192.168.0.142: icmp_seq=2 ttl=64 time=0.059 ms
64 bytes from 192.168.0.142: icmp_seq=3 ttl=64 time=0.045 ms
64 bytes from 192.168.0.142: icmp_seq=4 ttl=64 time=0.060 ms
64 bytes from 192.168.0.142: icmp_seq=5 ttl=64 time=0.069 ms
But When I am doing above commands on adb shell
, most of the command are not found. arp
and dig
is not present in android.
And when I ping device through adb shell with their hostname
, It gives me following error:
ping: unknown host example.local
But when I ping through ip
of device, It successfully ping:
$ ping 192.168.0.142
PING 192.168.0.142 (192.168.0.142) 56(84) bytes of data.
64 bytes from 192.168.0.142: icmp_seq=1 ttl=64 time=263 ms
64 bytes from 192.168.0.142: icmp_seq=2 ttl=64 time=231 ms
64 bytes from 192.168.0.142: icmp_seq=3 ttl=64 time=1.82 ms
64 bytes from 192.168.0.142: icmp_seq=4 ttl=64 time=1.99 ms
64 bytes from 192.168.0.142: icmp_seq=5 ttl=64 time=122 ms
64 bytes from 192.168.0.142: icmp_seq=6 ttl=64 time=5.63 ms
Above things are done in same network, but still I am not getting IP
through hostname
(When I used same command from adb shell
). How can I find IP
through their hostname
on android
device using adb shell
.
Does anyone know what I am doing wrong?