LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-05-2014, 12:24 PM   #1
doughyi8u
Member
 
Registered: Apr 2010
Posts: 254

Rep: Reputation: 10
how to get hostname from ip address


I'm trying to get a hostname from an ip address:

host <ipaddress>

but it doesn't give me the hostname. I tried nslookup and dig too but don't get the information I want.

in a nutshell I want the opposite of the host command used with a hostname to get the ip address,
 
Old 11-05-2014, 12:36 PM   #2
netnix99
Member
 
Registered: Jun 2011
Distribution: redhat, CentOS, OpenBSD
Posts: 298

Rep: Reputation: 99
It sounds like the reverse-lookup is not working correctly or not configured. Is this a local DNS server that you control or a public DNS server? If public, they may not offer/support reverse-lookups, or they can be very generic.

For instance, if you do a
Code:
host www.google.com
you get multiple IP addresses; one of which is 74.125.225.46.

If you do a
Code:
host 74.125.225.46
it responds with: ord08s06-in-f14.1e100.net
 
Old 11-05-2014, 12:37 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
That isn't a fault in the command. It's just that the IP doesn't have a PTR record set up.

You can read about PTR records and such here: http://help.dnsmadeeasy.com/spry_menu/ptr-record/

Additionally, sites on the internet at large might not support this, because they don't have PTR records, and because they are utilizing virtualhosts, and DNS does not support querying this way.

More information here on that: http://superuser.com/questions/33938...nting-to-an-ip

If you want to get fancy and get access to the entire TLD zone files, that you can turn into a database and query as you wish, you can visit here: http://www.verisigninc.com/en_US/cha...on/index.xhtml. This might not be what you are looking for as it probably contains nameserver info rather than ip mappings, but worth a mention.

Last edited by szboardstretcher; 11-05-2014 at 12:41 PM.
 
Old 11-05-2014, 12:40 PM   #4
doughyi8u
Member
 
Registered: Apr 2010
Posts: 254

Original Poster
Rep: Reputation: 10
that's exactly what I was trying to do. I was using the first address returned from:
host google.com

and then tried to get "google.com" to show up when I used:

host <google'sipaddress>

I've tried this on a few addresses but none of them give the actual hostname
 
Old 11-05-2014, 12:42 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Right. No reverse-dns set up.

It's particularly useful on Windows Domains to turn IP's into Hostnames. But the internet, not so much.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing IP address and hostname ashley75 Linux - General 7 05-19-2005 10:26 AM
hostname-------->ip address bruse Linux - Networking 2 04-18-2005 05:08 AM
how to use the hostname instead of ip address? tuxtamer Linux - Newbie 1 04-15-2005 07:29 AM
hostname to IP address bruse Linux - Networking 5 03-29-2005 11:21 PM
From IP address to hostname swmok Linux - Networking 1 08-22-2003 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration