how to find host name from IP with out login to th

2019-03-07 16:56发布

i need to find the host name of a UNIX host whose IP is known with out login to that UNIX host

11条回答
我只想做你的唯一
2楼-- · 2019-03-07 17:34

Use nslookup

nslookup 208.77.188.166 
...
Non-authoritative answer:
166.188.77.208.in-addr.arpa     name = www.example.com.
查看更多
We Are One
3楼-- · 2019-03-07 17:34

Another NS lookup utility that can be used for reversed lookup is dig with the -x option:

$ dig -x 72.51.34.34

; <<>> DiG 9.9.2-P1 <<>> -x 72.51.34.34
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12770
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1460
;; QUESTION SECTION:
;34.34.51.72.in-addr.arpa.      IN      PTR

;; ANSWER SECTION:
34.34.51.72.in-addr.arpa. 42652 IN      PTR     sb.lwn.net.

;; Query time: 4 msec
;; SERVER: 192.168.178.1#53(192.168.178.1)
;; WHEN: Fri Jan 25 21:23:40 2013
;; MSG SIZE  rcvd: 77

or

$ dig -x 127.0.0.1

; <<>> DiG 9.9.2-P1 <<>> -x 127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11689
;; flags: qr aa ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;1.0.0.127.in-addr.arpa.                IN      PTR

;; ANSWER SECTION:
1.0.0.127.in-addr.arpa. 10      IN      PTR     localhost.

;; Query time: 2 msec
;; SERVER: 192.168.178.1#53(192.168.178.1)
;; WHEN: Fri Jan 25 21:23:49 2013
;; MSG SIZE  rcvd: 63

Quoting from the dig manpage:

Reverse lookups -- mapping addresses to names -- are simplified by the -x option. addr is an IPv4 address in dotted-decimal notation, or a colon-delimited IPv6 address. When this option is used, there is no need to provide the name, class and type arguments. dig automatically performs a lookup for a name like 11.12.13.10.in-addr.arpa and sets the query type and class to PTR and IN respectively.

查看更多
对你真心纯属浪费
4楼-- · 2019-03-07 17:34

You can use traceroute command as well.

http://linux.die.net/man/8/traceroute

just use the traceroute it will show you the routing path with host names (IPs resolved)

查看更多
太酷不给撩
5楼-- · 2019-03-07 17:36

In most cases, traceroute command works fine. nslookup and host commands may fail.

查看更多
霸刀☆藐视天下
6楼-- · 2019-03-07 17:39
python -c "import socket;print(socket.gethostbyaddr('127.0.0.1'))"

if you just need the name, no additional info, add [0] at the end:

python -c "import socket;print(socket.gethostbyaddr('8.8.8.8'))[0]"
查看更多
Juvenile、少年°
7楼-- · 2019-03-07 17:47

The other answers here are correct - use reverse DNS lookups. If you want to do it via a scripting language (Python, Perl) you could use the gethostbyaddr API.

查看更多
登录 后发表回答