I hope this helps:
The Short Answer:
Add the following line in the Global section of /etc/samba/smb.conf:
disable netbios = yes
Prevent nmbd from starting at boot time with the following command:
pi@raspberrypi3b:~ $ sudo update-rc.d nmbd disable
You can verify that this disables nmbd with netstat -ln | grep 137 and netstat -ln | grep 138. Ports 137 & 138 are two ports used by netbios.
Here's how I got to the Short Answer:
pi@raspberrypi3b:~ $ sudo ps -e | grep nmbd
6555 ? 00:00:00 nmbd
pi@raspberrypi3b:~ $ netstat -ln | grep 137
udp 0 0 192.168.1.255:137 0.0.0.0:*
udp 0 0 192.168.1.27:137 0.0.0.0:*
udp 0 0 192.168.1.255:137 0.0.0.0:*
udp 0 0 192.168.1.28:137 0.0.0.0:*
udp 0 0 0.0.0.0:137 0.0.0.0:*
pi@raspberrypi3b:~ $ netstat -ln | grep 138
udp 0 0 192.168.1.255:138 0.0.0.0:*
udp 0 0 192.168.1.27:138 0.0.0.0:*
udp 0 0 192.168.1.255:138 0.0.0.0:*
udp 0 0 192.168.1.28:138 0.0.0.0:*
udp 0 0 0.0.0.0:138 0.0.0.0:*
These 3 commands tell us that nmbd is running under pid 6555, and that ports 137 & 138 are in use. We believe that nmbd is the user of these ports. Without knowing precisely how to disable nmbd at this point, let's determine the effect of setting the option disable netbios = yes in /etc/smb.conf. After making that change, restart samba
to have it re-read smb.conf:
pi@raspberrypi3b:~ $ sudo /etc/init.d/samba restart
[ ok ] Restarting nmbd (via systemctl): nmbd.service.
[ ok ] Restarting smbd (via systemctl): smbd.service.
pi@raspberrypi3b:~ $ netstat -ln | grep 137
udp 0 0 192.168.1.255:137 0.0.0.0:*
udp 0 0 192.168.1.27:137 0.0.0.0:*
udp 0 0 192.168.1.255:137 0.0.0.0:*
udp 0 0 192.168.1.28:137 0.0.0.0:*
udp 0 0 0.0.0.0:137 0.0.0.0:*
pi@raspberrypi3b:~ $ netstat -ln | grep 138
udp 0 0 192.168.1.255:138 0.0.0.0:*
udp 0 0 192.168.1.27:138 0.0.0.0:*
udp 0 0 192.168.1.255:138 0.0.0.0:*
udp 0 0 192.168.1.28:138 0.0.0.0:*
udp 0 0 0.0.0.0:138 0.0.0.0:*
CONCLUSION: Adding the option disable netbios = yes to smb.conf doesn't stop broadcasts on ports 137 and 138. Let's stop nmbd, and determine the effect:
pi@raspberrypi3b:~ $ sudo ps -e | grep nmbd
6555 ? 00:00:00 nmbd
pi@raspberrypi3b:~ $ sudo kill 6555
pi@raspberrypi3b:~ $ sudo ps -e | grep nmbd
pi@raspberrypi3b:~ $ netstat -ln | grep 137
pi@raspberrypi3b:~ $ netstat -ln | grep 138
CONCLUSION: Stopping nmbd stops activity on ports 137 and 138. Now, we must learn how to prevent nmbd from being started at boot time.
Where is nmbd started?
pi@raspberrypi3b:~ $ ls -l /etc/init.d | grep nmbd
-rwxr-xr-x 1 root root 2064 Mar 5 13:30 nmbd
CONCLUSION: nmbd startup script is in /etc/init.d and therefore controlled by update-rc.d
After reading man update-rc.d and postings in other forums, it seems there is some question as to exactly how to do this; i.e. which of the following commands should be used? :
sudo update-rc.d nmbd disable
-- OR --
sudo update-rc.d -f nmbd remove
Since disable sounds less permanent than remove, try that first :)
sudo update-rc.d nmbd disable
pi@raspberrypi3b:~ $ sudo reboot
...
Finally, let's check to make sure activity on ports 137 and 138 has been stopped, and that nmbd is not running:
pi@raspberrypi3b:~ $ sudo ps -e | grep nmbd
pi@raspberrypi3b:~ $ netstat -ln | grep 137
pi@raspberrypi3b:~ $ netstat -ln | grep 138
pi@raspberrypi3b:~ $
This appears to have done the deed. Let me know if this does what you needed.
pi@raspberrypi3b:~ $ nmbd --version Version 4.5.12-Debian– Seamus Jun 02 '18 at 13:23sudo systemctl stop nmbddisables the NetBIOS name, that's one step further, but that was all. Now it shows the actual IP address when scanning my LAN.sudo systemctl disable smbdstops the entire Samba server. What I must look into is to disable broadcasting of the IP not the NetBIOS name. I am stuck for now. – May Jun 02 '18 at 16:49netstat -an | grep 137Does it show anything? – Seamus Jun 03 '18 at 01:02udp 0 0 192.168.1.3:138 0.0.0.0:*<-- 137 Resultudp 0 0 192.168.1.3:137 0.0.0.0:*<--138 ResultThese are the results for
– May Jun 03 '18 at 12:58netstat -an | grep 137andnetstat -an | grep 138. The IP (192.168.1.3) is the IP of my Raspberry Pi. Basically without disabling and with disabling nmbd, the results stay the same. No difference noticed.sudo ps -e | grep nmbd) – Seamus Jun 03 '18 at 13:23sudo ps -e | grep nmbdshows nothing in terminal. I assume it is not running as I cannot see the NetBIOS name when scanning my LAN. – May Jun 03 '18 at 13:57netstat -an, instead ofnetstat -ln. Seeman netstatfor the diff, but theloption means list the active listeners. I changed that in the answer... Run that, and hopefully you'll see nothing listening – Seamus Jun 03 '18 at 15:37nenstat -lnin my post. – May Jun 03 '18 at 17:19grep 137&grep 138. You've listed all of the ports, and that's fine - this is what I'd expect to see. From the output you have listed, there's nothing on 137 or 138. I think you've squashed it!nmbdis disabled, and your Samba server is now "hidden" (as in not broadcasting its presence or advertising its services any longer). I think we're done. If you disagree, please let me know. – Seamus Jun 03 '18 at 21:07