On macOS, how do I get the IP address of a Windows machine on my local network?

7,664

Solution 1

The command-line smbutil utility is what you are after:

$ smbutil

usage: smbutil [-hv] subcommand [args]
where subcommands are:
 help       display help on specified subcommand
 lookup     resolve NetBIOS name to IP address
 status     resolve IP address or DNS name to NetBIOS names
 view       list resources on specified host
 dfs        list DFS referrals
 identity   identity of the user as known by the specified host
 statshares list the attributes of mounted share(s)

You can look up a machine's IP address with smbutil lookup <name> in Terminal:

$ smbutil lookup Example-Name
Got response from 192.168.1.110
IP address of Example-Name: 192.168.56.1
IP address of Example-Name: 192.168.1.110

Or look up the machine's name with smbutil status <IP>:

$ smbutil status 192.168.1.110
Using IP address of 192.168.1.110: 192.168.1.110
Workgroup: WORKGROUP
Server: EXAMPLE-NAME

(Credit to 11rcombs for telling me about this.)

Solution 2

If you cannot get smbutil to work - sometimes it doesn't & I'm not good enough with SMB to know why, then arp might be useful instead.

For example [content trimmed to relevant lines only]
ol-server is a Windows machine I am currently already connected to. I have drives mounted & an open RDC session.

TetsMac:~ glee$ smbutil lookup ol-server
smbutil: unable to resolve ol-server: No route to host
TetsMac:~ glee$ arp -a
ol-server (192.168.0.3) at 0:21:91:e7:9c:a3 on en1 ifscope [ethernet]
Share:
7,664

Related videos on Youtube

Andrea
Author by

Andrea

Updated on September 18, 2022

Comments

  • Andrea
    Andrea over 1 year

    I can connect to a Windows PC on my network for file sharing in Finder in the “Shared” section or with “Go > Connect to server…”, but how do I find out its IP address?

  • Tetsujin
    Tetsujin over 6 years
    Doesn't always work - though I'm not good enough with smb to know why.
  • Eliad Cohen
    Eliad Cohen over 6 years
    What is wrong with this answer?
  • r_alex_hall
    r_alex_hall over 5 years
    What's wrong is you write "I think" and you don't know, and the OP and visitors are looking for certain, tested answers, and ping <pc-name> doesn't work (in my test, anyway). Also what you give about wireshark gives general instructions without specific steps or commands that would accomplish the task.