How to resolve netbios names with osx

Hi I'm new to osx and trying to resolve the netbios name of a windows machine. When I try to ping it I get the error cannot resolve hostname. When I use the command smbutil lookup %hostname% it will resolve.

When I ping the ip directly it works fine and this was working on a previous mac which I had to return and replace with my new one. I am able to resolve it from another windows machine on my network.

Essentially I just want to be able to ping my windows machine. Any help would be greatly appreciated.


Solution 1:

As you mentioned, smbutil lookup will resolve the name to an IP address:

$ smbutil lookup qx-2000
Got response from 10.0.1.21
IP address of qx-2000: 10.0.1.21

We can extract the IP address from this output:

$ smbutil lookup qx-2000 2>&1 | tail -n 1 | cut -d : -f 2
 10.0.1.21

Then we can use that in our argument to ping:

$ ping $(smbutil lookup qx-2000 2>&1 | tail -n 1 | cut -d : -f 2)
PING 10.0.1.21 (10.0.1.21): 56 data bytes
64 bytes from 10.0.1.21: icmp_seq=0 ttl=128 time=4.823 ms
64 bytes from 10.0.1.21: icmp_seq=1 ttl=128 time=7.373 ms
64 bytes from 10.0.1.21: icmp_seq=2 ttl=128 time=4.820 ms
...