24/7/365 Support

Troubleshooting Samba server in Ubuntu

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:

[global]

log level = 0

log file = /var/log/samba/log.%m

include = /etc/samba/smb.conf.%m

Now create a new configuration file for a specific client:

$ sudo vi /etc/samba/smb.conf.client1

[global]

log level = 3

Similarly, you can create separate logs for each Samba user:

[global]

log level = 0

log file = /var/log/samba/log.%u

include = /etc/samba/smb.conf.%u

Checking Samba configuration

Follow these steps to check Samba configuration:

Check the registered users and accounts in the Samba server user database with the pdbedit command:

$ sudo pdbedit -L

Check the shares with the smbtree command:

Use the testparm command to find any errors in the Samba configuration:

$ testparm

Check for allowed users and group names. Make sure that group names start with the @ symbol.

Back up your configuration files and then use minimal configuration to test Samba:

[global]

workgroup = WORKGROUP

security = user

browsable = yes

[temp]

path = /tmp

public = yes

Publicly writable directories are not good for server security.

Remove the preceding configuration as soon as testing is finished.

Test your configuration with smbcclient. It should list all Samba shares:

$ smbclient -L localhost -U%

See also

Samba docs troubleshooting at https://www.samba.org/samba/docs/using_samba/ch12.html

Help Category:

What Our Clients Say