question

ToddChester-3826 avatar image
0 Votes"
ToddChester-3826 asked ToddChester-3826 commented

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


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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered ToddChester-3826 commented

How about a good old ping?

 ping -n 1 test10

If you are looking to write code use Powershell.

 (Test-NetConnection test10).RemoteAddress.IPAddressToString



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ping 's call to DNS does not resolve the NETBIOS name.

I am looking for a cmd call.

0 Votes 0 ·

Hi,

In most cases the ping will return the desired result, as the netbios name is normally the same as the DNS name.

Another option is to use the nbstat -a <netbios name> but this has a number of dependencies on the configuration of the target machine to work.

If you are looking for a specific format or response, please provide some more details.

Gary.

0 Votes 0 ·

nbstat -a <netbios name> Does ot find it. It give me MY IP not the one requested

0 Votes 0 ·
MotoX80 avatar image
1 Vote"
MotoX80 answered ToddChester-3826 commented

I brought up a Win10 test VM and changed the NIC from DHCP to use a hardcoded IP address that had no DNS entry. I pinged the machine and got back an IPV6 address. I removed IPV6 from the network on the VM and then ping was able to see the IPV4 address.

I just tried it again and ping failed. But the Windows Explorer also failed. On the VM I tried to use the Windows Explorer to see what it saw in the Network folder and it reported that network discovery was not started. I ran my PS script from the below link and rebooted.

https://docs.microsoft.com/en-us/answers/questions/302088/how-to-switch-from-a-call-by-ip-address-to-a-call.html

Both Ping and Explorer now work.

This site says that ping uses the Netbios name.

https://www.cbfive.com/ping-vs-nslookup/

If ping fails for you, does Explorer still work?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If ping fails for you, does Explorer still work?

WE works perfectly, except for the home edition, where you don't have the option of adding that column. W11-Pro also works.

I need a cmd line way of doing it, because of the home edition restriction. And I want to stay away rfom power shell as I may be calling the command from one of my programs in the future.

0 Votes 0 ·
MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 commented

except for the home edition,

I'm running Win10 Home 2H1 and I can add the IP address column.

141039-capture.jpg


Check your network settings on both machines to see if Netbios is enabled.

141040-capture1.jpg



capture.jpg (73.3 KiB)
capture1.jpg (47.4 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I also noticed that the discovery method is WSD, not netbios (If that's even possible).

141054-capture.jpg

Check this out:

https://www.tenforums.com/network-sharing/82943-wsd-vs-netbios-network-discovery.html





0 Votes 0 ·
capture.jpg (27.7 KiB)

Here is my W11 VM discovering my Samba Server, also with WSD

https://ibb.co/5kqyh0F

(Couldn't get the image insert to work)

0 Votes 0 ·

Any idea how to get the IPv4 address with WSD from the command line?

0 Votes 0 ·

There might be something in WMI but I am out of town for a few days and won't have any way to test that.

0 Votes 0 ·

Well, I can't find anything. So let's take a step back and analyze the overall problem. What is the real problem that you are trying to address? Typically, if you want to access another machine then DNS is the preferred solution. Why can't you use DNS?

0 Votes 0 ·
ToddChester-3826 avatar image
0 Votes"
ToddChester-3826 answered

The local network computer are not in DNS.

There are two problems

1) folks naming their workstations the same name as the server

2) the add columns on a few computers is missing half the view section. So I never know when I can use Windows Explorer to find IP's.

So I am looking for a command line way to do a WDS lookup. I can write it myself if I can find the correct api call.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered

The local network computer are not in DNS.

Why not? Is there some network limitation? Who "owns" the network? Is this a home environment? A business environment?

1) folks naming their workstations the same name as the server

Who "owns" the desktop support? If you have a business environment, then end users should not get to pick their own workstation name. And it certainly should not be the same name as the server. What kind of server is this? Are you using Windows Server Essentials? What about Active Directory? Who supports/owns DNS?



the add columns on a few computers is missing half the view section. So I never know when I can use Windows Explorer to find IP's.

If you need to get IP's, then all machines should be registered in DNS. That's what it's there for.


So I am looking for a command line way to do a WDS lookup. I can write it myself if I can find the correct api call.


No, this is an XY problem.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ToddChester-3826 avatar image
0 Votes"
ToddChester-3826 answered

I am the network administrator.

The DHCP server is not linked to the DNS because it does not need to be for a workgroup. The dhcp server resides in a Watchguard firewall. It only does pass through DNS, not local DNS.

The server is NOT a Windows server. It is Samba (Fedora). Windows servers are too buggy, slow, and expensive to administer. Samba is set and forget.

I did find the duplicate machine name with arp. It was the ONLY workstation I did not configure myself.
My question is how to I duplicate what Windows Explorer does with WDS from the command line.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 commented


The DHCP server is not linked to the DNS because it does not need to be for a workgroup. The dhcp server resides in a Watchguard firewall. It only does pass through DNS, not local DNS.

Again, why not? If you want machines on your local network to "see" each other, then use DNS!


The server is NOT a Windows server. It is Samba (Fedora). Windows servers are too buggy, slow, and expensive to administer. Samba is set and forget.

Well then maybe you should be asking this question in a Samba forum.

I did find the duplicate machine name with arp. It was the ONLY workstation I did not configure myself.
My question is how to I duplicate what Windows Explorer does with WDS from the command line.

I don't know. I can't find a solution for you. Maybe some other other forum user can help you. As I see it, the correct solution is to use DNS. But you have not explained why that is not a viable solution.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What I am looking for is how to I duplicate what Windows Explorer does with WDS from the command line. Please do not go off on a tangent.

0 Votes 0 ·

I am not going off on a tangent. This is an XY problem. https://xyproblem.info/ You have a problem resolving names to IP addresses. You are convinced that the solution is to use some unknown command line tool to query WDS names. I have not been able to find any such tool that will do that. You are free to wait to see if some other forum user knows of such a tool.

My position is that DNS is correct solution for machines that want to be able to find each other. You have not adequately explained why that is not a viable solution. And I have to accept some blame for that, because I do not understand the implication of having "dhcp server resides in a Watchguard firewall It only does pass through DNS, not local DNS.", Well if you are using some third party firewall or DNS solution, then what are your expectations??? That I understand what that software does and what its limitations are?? I never heard of Watchdog. Have you asked this question in a Watchdog forum as to how you can register DNS names?

0 Votes 0 ·
ToddChester-3826 avatar image
0 Votes"
ToddChester-3826 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 edited

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
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

"zero neighbors were found"

Widows Explorer in W11 find all three neighbors using WDS.

Anyone know the WDS API call that Windows Explorer is using?

0 Votes 0 ·

Did you change the $MyNet variable to point to your subnet? If you just run the Get-NetNeighbor command does it return anything?

 Get-NetNeighbor -AddressFamily IPv4 
0 Votes 0 ·
ToddChester-3826 avatar image
0 Votes"
ToddChester-3826 answered

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).

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.