Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I want to find out how the hostname of a remote linux machine on my LAN is, how can I achieve this given I don't have access via SSH etc.?

Probably depends if linux is part of a WINS domain I suppose.

share|improve this question
    
What information do you have? – David Schwartz Mar 14 '13 at 9:20
    
Only the IP address of the machine. – JohnnyFromBF Mar 14 '13 at 9:43

You'd have to specify the term hostname more closely. If you are looking for the name as it is known to the DNS server that you don't want to use - there is no way of knowing except for actually asking that DNS server.

If you are simply guessing, nmap can be of good use. For example, if there is a smbd running on that server, the output of nmap -A might look like this:

Host script results:
| smb-security-mode:
|   Account that was used for smb scripts: guest
|   User-level authentication
|   SMB Security: Challenge/response passwords supported
|_  Message signing disabled (dangerous, but default)
|_smbv2-enabled: Server doesn't support SMBv2 protocol
|_nbstat: NetBIOS name: FOOBAR, NetBIOS user: <unknown>, NetBIOS MAC: <unknown>
| smb-os-discovery:
|   OS: Unix (Samba 3.5.6)
|   Computer name: foobar
|   Domain name: lan
|   FQDN: foobar.lan
|   NetBIOS computer name:
|_  System time: 2013-03-14 17:02:27 UTC+1

Other services might give hints about the name of the machine as well.

share|improve this answer
    
That would be a solution, of course it depends on a listening smbd deamon. – JohnnyFromBF Mar 14 '13 at 17:18

In the absence of a DNS server, this might work:

traceroute 1.2.3.4

Alternatively, if the server in question is exporting Samba shares, you could do this:

smbclient -L 1.2.3.4

This depends on whether you have a working DNS server set up on your LAN that has the necessary information. If it does, this command should do what you need:

nslookup 1.2.3.4

or

host 1.2.3.4

Finally, another useful command is

arp -a
share|improve this answer
    
There's no DNS server.. – JohnnyFromBF Mar 14 '13 at 14:41
    
@Ian, yes I finally read the title and not only the body of your question and figured that out. Sorry. Anyway, the traceroute and smbclient options might work. – terdon Mar 14 '13 at 14:45
2  
traceroute also uses dns to resolve names – barbaz Mar 14 '13 at 15:59
1  
@barbaz thanks, was not sure about that one. – terdon Mar 14 '13 at 16:00

Fingerd (and xinetd) are easy to set up and require no maintenance.

$ finger root@10.3.0.3
[10.3.0.3:79]

Welcome to Linux version 3.5.7-12-tryggve at tryggve.lan !
(...)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .