CLI: How can I get an IP address from a CIFS NETBIOS name?

Todd Chester 646 Reputation points
2021-10-15T19:54:40.62+00:00

Hi All,

Windows 10, pro and home

In Windows Explorer (not IE), when I click on Network in the left column, I get a list of computer CIFS broadcast names in the right pane. Well, after a bit.

I know how to add the IP column in Windows explorer, but ..

Is there a way to translate CIFS NETBIOS broadcast names into IP addresses from the command line?

Many thanks,
-T

Windows 10 Network
Windows 10 Network
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Network: A group of devices that communicate either wirelessly or via a physical connection.
2,272 questions
0 comments No comments
{count} votes

12 answers

Sort by: Newest
  1. Todd Chester 646 Reputation points
    2021-10-24T00:24:50.333+00:00

    Hi Moto,

    Some of those commands find things, other do not.

    What I am really after is how does Windows Explorer do it.

    -T


  2. MotoX80 31,581 Reputation points
    2021-10-23T00:03:20.667+00:00

    but never itself

    The pc that you're running it on isn't "in the neighborhood" so to speak. Just use ipconfig or this PS command to get the IP.

    (get-netipconfiguration).ipv4address.ipaddress
    

    For netbios, try running nbtstat.

    C:\Temp>nbtstat
    
    Displays protocol statistics and current TCP/IP connections using NBT
    (NetBIOS over TCP/IP).
    
    NBTSTAT [ [-a RemoteName] [-A IP address] [-c] [-n]
            [-r] [-R] [-RR] [-s] [-S] [interval] ]
    
      -a   (adapter status) Lists the remote machine's name table given its name
      -A   (Adapter status) Lists the remote machine's name table given its
                            IP address.
      -c   (cache)          Lists NBT's cache of remote [machine] names and their IP addresses
      -n   (names)          Lists local NetBIOS names.
      -r   (resolved)       Lists names resolved by broadcast and via WINS
      -R   (Reload)         Purges and reloads the remote cache name table
      -S   (Sessions)       Lists sessions table with the destination IP addresses
      -s   (sessions)       Lists sessions table converting destination IP
                            addresses to computer NETBIOS names.
      -RR  (ReleaseRefresh) Sends Name Release packets to WINS and then, starts Refresh
    
      RemoteName   Remote host machine name.
      IP address   Dotted decimal representation of the IP address.
      interval     Redisplays selected statistics, pausing interval seconds
                   between each display. Press Ctrl+C to stop redisplaying
                   statistics.
    
    0 comments No comments

  3. Todd Chester 646 Reputation points
    2021-10-22T23:15:59.377+00:00

    I forgot to change the subnet. It found two of the five, but never itself from W10 and W11. W7 does not respond to WDS, but showed up on Windows explorer as netbios but only on the W7 machine. Fedora 33 should be dead quiet. Samba server was always found (wsdd server).

    0 comments No comments

  4. MotoX80 31,581 Reputation points
    2021-10-22T21:38:15.133+00:00

    See if this Powershell script works for you.

    $MyNet = "192.168.1.*"       # Your subnet      
    $neighbors = (Get-NetNeighbor -AddressFamily IPv4 | Where-Object {($_.IPAddress -like $MyNet) }).IPAddress 
    "{0} neighbors were found" -f $neighbors.count
    $rpt = foreach ($ip in $neighbors) {
        $name = Resolve-DnsName $ip -LlmnrNetbiosOnly -ErrorAction SilentlyContinue -QuickTimeout
        if ($name) {
            [PSCustomObject]@{
                 IP        = $ip 
                 Name      = $name.namehost
            }
        }
    }
    $rpt
    

  5. Todd Chester 646 Reputation points
    2021-10-22T01:25:43.16+00:00

    If you don't know of a command line tool and you don't know how Windows Explorer calls WDS, then please do not waste your time on alternate solutions. I do very much appreciate your help, but please do stay on subject.

    0 comments No comments