In this recipe, we will look at the various tools available for troubleshooting Samba shares.
How to do it…
Samba troubleshooting can be separated in to three parts: network connectivity, Samba process issues, and Samba configuration issues. We will go through each of them step by step. As a first step for troubleshooting, let's start with network testing.
Checking network connectivity
Follow these steps to check network connectivity:
Send ping requests to the Samba server to check network connectivity:
$ ping samba-server-ip
Check name resolution. Ping the Samba server by its name. Windows uses netbios for name resolution:
$ ping samba-server-name
Check the Samba configuration for network restrictions. Temporarily open Samba to all hosts.
Use tcpdump to check Samba network communication. Start tcpdump as follows and let it run for some time while accessing the Samba server from clients. All packets will be logged in a file named tcpdump in the current directory:
$ sudo tcpdump -p -s 0 -w tcpdumps port 445 or port 139
If you know the client IP address, you can filter tcpdumps with the following command:
$ sudo tcpdump -s 0 -w tcpdumps host client_IP
Connect to the Samba process with telnet:
$ echo "hello" | telnet localhost 139
Check whether your Samba server uses a firewall. If so, check the allowed ports on your firewall. If the firewall is on, make sure you have allowed the Samba ports as follows:
Try connecting to FTP or a similar TCP service on the Samba server. This may identify the problems with the TCP stack.
Use nmblookup to test netbios name resolution for Windows systems.
Checking the Samba service
Follow these steps to check Samba service:
Check whether the Samba service has started properly:
$ sudo service samba status
Use netstat to check the Samba daemon is listening on the network:
$ sudo netstat -plutn
Use ps to check the Samba processes. Look for the process name, smbd, in the output of the following command:
$ ps aux
Use strace to view the Samba process logs. This will list all filesystem activities by smbd process:
$ strace smbd
Checking Samba logs
Follow these steps to check Samba logs:
Check Samba log files for any warning or errors.
Increase the log level to get more debugging information:
[global]
log level = 3
Enable logging for a specific client with client-specific configuration. First, set the following options under smb.conf to enable client-specific configuration: