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
netstat -an | grep 137
Does it show anything?sudo ps -e | grep nmbd
)netstat -an
, instead ofnetstat -ln
. Seeman netstat
for the diff, but thel
option means list the active listeners. I changed that in the answer... Run that, and hopefully you'll see nothing listening