LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-17-2009, 08:31 AM   #1
otkaz
LQ Newbie
 
Registered: Apr 2009
Location: Houston, TX
Posts: 26

Rep: Reputation: 0
how to lookup a hostname of a networked computer


is there a command or terminal app that can lookup the hostname of a networked computer? doesn't matter to me if its by mac or ip.
I'm using ubuntu
 
Old 06-17-2009, 08:50 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 11,201
Blog Entries: 3

Rep: Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427Reputation: 1427
Hi,

Welcome to LQ!

You could 'arp';

Quote:
excerpt from 'man arp';
arp - Linux ARP kernel module.
DESCRIPTION
This kernel protocol module implements the Address Resolution Protocol defined in RFC 826. It is used to convert between Layer2 hardware addresses and IPv4 protocol addresses on directly connected networks. The user normally doesn't interact directly with this module except to configure it; instead it provides a service for other protocols in the kernel.

A user process can receive ARP packets by using packet(7) sockets. There is also a mechanism for managing the ARP cache in user-space by using netlink(7) sockets. The ARP table can also be controlled via ioctl (2) on any PF_INET socket.

The ARP module maintains a cache of mappings between hardware addresses and protocol addresses. The cache has a limited size so old and less frequently used entries are garbage-collected. Entries which are marked as permanent are never deleted by the garbage-collector. The cache can be directly manipulated by the use of ioctls and its behaviour can be tuned by the sysctls defined below.

When there is no positive feedback for an existing mapping after some time (see the sysctls below) a neighbour cache entry is considered stale. Positive feedback can be gotten from a higher layer; for example from a successful TCP ACK. Other protocols can signal forward progress using the MSG_CONFIRM flag to sendmsg(2). When there is no forward progress ARP tries to reprobe. It first tries to ask a local arp daemon app_solicit times for an updated MAC address. If that fails and an old MAC address is known an unicast probe is send ucast_solicit times. If that fails too it will broadcast a new ARP request to the network. Requests are only send when there is data queued for sending.

Linux will automatically add a non-permanent proxy arp entry when it receives a request for an address it forwards to and proxy arp is enabled on the receiving interface. When there is a reject route for the target no proxy arp entry is added.
BTW, 'arp -a' will provide you with information for your LAN in a 'BSD' format.
 
Old 06-17-2009, 09:11 AM   #3
otkaz
LQ Newbie
 
Registered: Apr 2009
Location: Houston, TX
Posts: 26

Original Poster
Rep: Reputation: 0
awesome thanks onebuck that was exactly what I was looking for. I knew about arp command, but never noticed it returned the hostname. I was using nmap -PN 192.168.1.65 | grep -e 'Interesting ports on' | awk '{print $4}' but it was very slow
 
Old 06-17-2009, 10:02 AM   #4
otkaz
LQ Newbie
 
Registered: Apr 2009
Location: Houston, TX
Posts: 26

Original Poster
Rep: Reputation: 0
arp -a only seems to have entries after I scan the ip with nmap, but has nothing before the scan...
 
Old 06-17-2009, 10:21 AM   #5
farslayer
Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,228
Blog Entries: 5

Rep: Reputation: 189Reputation: 189
reverse lookup if you have DNS running on your network..

dig -x ip.add.re.ss
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Hostname lookup failure chandrait2004 Linux - Newbie 3 06-23-2011 03:23 PM
Lookup hostname from IP address Geneset Linux - Networking 6 02-11-2011 01:16 AM
Odd hostname lookup problem max_sipos Linux - Networking 3 11-15-2004 11:29 AM
Problem with networked printing with CUPS-- hostname showing up where it shouldn't pingswept Linux - General 1 06-29-2004 09:38 PM
Networked computer can't see page served from other Networked computer Travis86 Linux - Networking 2 12-30-2002 01:38 PM


All times are GMT -5. The time now is 09:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration