LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-10-2007, 04:24 AM   #1
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Rep: Reputation: 15
Resolve hostname from IP


Simple questions can I resolve a hostname from an IP address

When I work with windows at work I can ping -a to resolve a hostname but I would like to do this with linux?
 
Old 10-10-2007, 04:33 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You can use nslookup (deprecated) or dig:
Code:
nslookup xx.xx.xx.xx
dig -x xx.xx.xx.xx
 
Old 10-10-2007, 04:34 AM   #3
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Original Poster
Rep: Reputation: 15
Cheers mate I will try that later
 
Old 10-10-2007, 05:07 AM   #4
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Original Poster
Rep: Reputation: 15
I tired both of those options but neither of them work
 
Old 10-10-2007, 05:12 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Please define "neither of them work". Did the commands ran, or they do not exist? You can also try
Code:
host xx.xx.xx.xx

Last edited by bathory; 10-10-2007 at 05:14 AM.
 
Old 10-10-2007, 05:15 AM   #6
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Original Poster
Rep: Reputation: 15
Yes they both ran but neither displayed the hostname afterwards

host didnt work either

Last edited by cornish; 10-10-2007 at 05:16 AM.
 
Old 10-10-2007, 05:36 AM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You should get an answer like this:
Code:
dig -x 209.85.135.147

; <<>> DiG 9.2.2 <<>> -x 209.85.135.147
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49976
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0

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

;; ANSWER SECTION:
147.135.85.209.in-addr.arpa. 86165 IN   PTR     mu-in-f147.google.com.

;; AUTHORITY SECTION:
135.85.209.in-addr.arpa. 86165  IN      NS      ns1.google.com.
135.85.209.in-addr.arpa. 86165  IN      NS      ns4.google.com.
135.85.209.in-addr.arpa. 86165  IN      NS      ns3.google.com.
135.85.209.in-addr.arpa. 86165  IN      NS      ns2.google.com.

;; Query time: 2 msec
;; SERVER: 193.0.0.195#53(193.0.0.195)
;; WHEN: Wed Oct 10 13:29:15 2007
;; MSG SIZE  rcvd: 152

host 209.85.135.147
147.135.85.209.in-addr.arpa domain name pointer mu-in-f147.google.com.
 
Old 10-10-2007, 05:44 AM   #8
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Original Poster
Rep: Reputation: 15
I get this

Quote:
mark@nb10001L:/etc$ dig -x 10.179.108.11

; <<>> DiG 9.3.4 <<>> -x 10.179.108.11
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55919
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

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

;; AUTHORITY SECTION:
10.in-addr.arpa. 600 IN SOA prisoner.iana.org. hostmaster.root-servers.org. 2002040800 1800 900 604800 604800

;; Query time: 44 msec
;; SERVER: 10.179.104.46#53(10.179.104.46)
;; WHEN: Wed Oct 10 11:42:09 2007
;; MSG SIZE rcvd: 121
The host should be myPC
 
Old 10-10-2007, 05:45 AM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Cornish might be wanting to do this on his lan without a nameserver running.

Maybe try "arp <ipaddress>" which will return the name and MAC address if the target is listed in the kernel arp table.

If it doesn't exist in the table, you could ping the ip first:
Code:
arp 192.168.1.103
192.168.1.103 (192.168.1.103) -- no entry
> ping -c 1 192.168.1.103
PING 192.168.1.103 (192.168.1.103) 56(84) bytes of data.
64 bytes from 192.168.1.103: icmp_seq=1 ttl=64 time=10.5 ms

--- 192.168.1.103 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.551/10.551/10.551/0.000 ms
> arp 192.168.1.103
Address                  HWtype  HWaddress           Flags Mask            Iface
laser                    ether   00:0E:7F:42:6C:65   C                     eth0

Last edited by jschiwal; 10-10-2007 at 05:47 AM.
 
Old 10-10-2007, 05:52 AM   #10
cornish
Member
 
Registered: May 2005
Location: Sussex, England
Distribution: Ubuntu 7.10
Posts: 131

Original Poster
Rep: Reputation: 15
There is a DNS running on the LAN as I can ping the device via its hostname
 
Old 10-10-2007, 10:21 AM   #11
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
is the rDNS entry in the DNS server ? just because it can resolve a forward lookup doesn't mean they setup the reverse..

Your dig query shows 1 Question and 0 Answers.
Dig queried your internal DNS server (10.179.104.46) and your server basically responded "I don't Know"
 
  


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
Basic command to resolve ip to hostname daemonkl Linux - Newbie 15 06-03-2014 11:07 PM
resolve hostname linuxtesting2 Solaris / OpenSolaris 5 03-20-2007 12:27 AM
A script to thoroughly resolve a hostname into IP addresses ahz10 Programming 1 08-23-2006 04:40 PM
DNS bind cant resolve IP and hostname dwarf007 Linux - Software 1 01-14-2006 08:42 AM
Unable to resolve hostname adirock2 Linux - Networking 14 07-06-2005 02:08 AM

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

All times are GMT -5. The time now is 08:44 PM.

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