2

My friend has a PC that uses Windows, and I want to know the name of that computer. All I know now is that his IP address is 10.0.0.2, how can I get his computer's name from my Linux box?

slm
  • 363,520
  • 117
  • 767
  • 871
Kokizzu
  • 9,257
  • 12
  • 55
  • 82

2 Answers2

6

How about:

nmblookup -A 10.0.0.2

and then a grep ?

DaLynX
  • 251
  • 1
  • 5
0

Building on the answer provided by @DaLynX, you could have :

function net.ip.netbios.lookup {
    nmblookup -A "$1" | 
    awk 'NR>1 && $1 !~ /MAC/ && $1 && $1 !~ /__MSBROWSE__/ {print $1}' | 
    sort -u
}

Which takes you from this

$ nmblookup 192.168.211.86
Looking up status of 192.168.211.86
        ITSNOWY         <00> -         B <ACTIVE>
        WORKGROUP       <00> - <GROUP> B <ACTIVE>
        ITSNOWY         <20> -         B <ACTIVE>
        WORKGROUP       <1e> - <GROUP> B <ACTIVE>
        WORKGROUP       <1d> -         B <ACTIVE>
        ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE>

        MAC Address = 08-2E-5F-07-88-19

$ 

To this

$ net.ip.netbios.lookup 192.168.211.86
    ITSNOWY
    WORKGROUP
$
ychaouche
  • 945
  • 8
  • 25