Closed alex-smeshkov closed 5 months ago
libsmb2 does not support NetBIOS
name lookup. The second one is Bonjour
which is done by Apple's Darwin operating system and is not part of this library.
@amosavian Thank you for your response. Does AMSMB2
support NetBIOS
/ Bonjour
or should I use custom name resolving and create smb
URLs only with IP addresses?
NetBIOS is an entirely different protocol. I tried to implement packet encoder/decoder but did not write a complete library for that. However, libdsm
does have NetBIOS name lookup. You can use wrappers like TOSMBClient and use it for name lookup, then pass retrieved ip address to AMSMB2
.
NSNetServiceBrowser
can be used for Bonjour
lookup on Apple platforms, but you don't need to use it directly. As you noted in question, smb://timecapsule.local/
already works.
Please don't spend time on NBNS (NetBIOS Name Service / WINS). NetBIOS only exist for SMB1 and as more and more servers start being deployed with a default to have SMB1 disabled completely, NetBIOS name resolution will stop working.
https://support.microsoft.com/en-au/help/4034314/smbv1-is-not-installed-by-default-in-windows
What we need is either DNS-SD and/or LLMNR
On Tue, Sep 4, 2018 at 5:34 AM, Amir Abbas Mousavian < notifications@github.com> wrote:
NetBIOS is an entirely. I tried to implement packet encoder/decoder but did not write a complete library for that. However, libdsm does have NetBIOS name lookup. You can use wrappers like TOSMBClient https://github.com/TimOliver/TOSMBClient/tree/master/TOSMBClient and use it for name lookup, then pass retrieved ip address to AMSMB2.
NSNetServiceBrowser can be used for Bonjour lookup on Apple platforms, but you don't need to use it directly. As you noted in question, smb://timecapsule.local/ already works.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sahlberg/libsmb2/issues/70#issuecomment-418181971, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeNkFzJUwe9Ce8R7b87mqRs7dLgKqAbks5uXYQqgaJpZM4WX-Az .
@sahlberg You are right. I disabled smb1 on my mac and it gave up broadcasting NBNS packets.
DNS-SD (aka. Bonjour or mDNS) already implemented on Apple platforms. NSNetServiceBrowser
class provides discovering functionality. Windows 10 servers support mDNS, but older Windows servers must install Bonjour software which is not the case for most users. Linux distributions supports it via Avahi.
LLMNR is an interesting case. I could not find any non-GPL opensource LLMNR discovery library written in C or objective-c. Someone said Microsoft is deprecating LLMNR in favor of mDNS.
@amosavian @sahlberg Thank you, you're great!
Does libsmb2
support automatic SMB servers discovering?
I have 2 servers in my network:
Samba
library (smbtree
module). Probably it uses some other broadcasting mode too, but I don't know which one.Do you know what is a standard for SMB2/3 broadcast? How to find this type of servers automatically?
@alex-smeshkov I have WD My Cloud and it supports Bonjour. Indeed Bonjour became de facto standard for new devices, and Windows 10. Linux supports it via Avahi, which is bundled with some distributions.
If your code is Swift or Objective-C, use NSNetServiceBrowser
class to find servers. There are various thrid-party libraries for other operating systems.
I'm stuck in this area at the moment with an iOS application. I'm using the AMSMB2 wrapper. On my local network there are 3 Macs and 1 Windows 10 machine. The getaddrinfo() call inside libsmb2's socket.c finds all 4 by name. Perfect.
On one of my tester's network, getaddrinfo() fails to find their Windows machines by name. Unfortunately, they don't have any Macs.
I wrote a simple Playground to search for '_smb._tcp' with NetServiceBrowser. On my local network it only finds the 3 Macs, but not the PC. Using 'mDNS Tool' on a Mac I can see the PC under another (non-SMB) service type.
I have a few questions:
Is there something I need to enable on Windows 10 to enable mDNS for smb?
Is there a better way to support finding Windows machines by name? Especially older Windows, as many of my users will not be on Windows 10. I don't want to ask users to install Bon Jour on their PC.
@MynaBay Windows has its own network discovery protocol (LLMNR) which is already discussed in this thread. I could find no usable opensource project for it.
@amosavian Thanks. I saw LLMNR above but it was also mentioned that it's being deprecated. Any idea why NetServiceBrowser doesn't show my Windows machine? I attached a playground to search for SMB.
SMB Service.playground.zip
declaring github issues bancruptcy
The same url (e.g. smb://timecapsule/) doesn't work in libsmb2 while it works correctly in Samba library when using mDNS. In libsmb2 only smb://timecapsule.local/ URL is working, which results in problems with porting from Samba to libsmb2.