SOLVING THE SAMBA/WINDOWS HOST GOTCHA


If the solutions described in "Solving Samba problems with Windows passwords" did not resolve your Samba conflicts, odds are you've run into the famous host gotcha.

Perhaps you configured your /etc/hosts file to list all the computers on your network, figuring that this file would provide the needed IP addresses if all else fails. And, sure enough, Samba is configured to check this file--or so it seems. Actually, what Samba checks is the gethostbyname() function. But some distributions--notably, Red Hat--are configured so that this function returns only the name of the current host, not the contents of /etc/hosts.

To see the rest of the computers on your network, you'll need to edit the Samba configuration file and change the name resolve order from the default "host lmhost broadcast win" to "lmhost broadcast win" so that gethostbyname() doesn't come into the picture.

To make the needed changes to the Samba configuration file, do the following:

1. In a terminal window, open a superuser session. Type su, press [Enter], and supply your root password.

2. Launch a text editor, and open /etc/smb.conf.

NOTE: On some systems, this file is located in /etc/samba/smb.conf.

3. Look for the section that begins with the following text: "#All NetBIOS names must be resolved to IP addresses"

4. Remove the semicolon at the beginning of the line ";name resolve order =..."

5. On the same line, delete the word "host." Make sure the line contains "lmhosts."

6. Save /etc/smb.conf (or, if the file was located in /etc/samba, save the file as /etc/samba/smb.conf).

7. Open the file named lmhosts in the same directory. If no such file exists, create a new text file.

8. In lmhosts, carefully type the IP address of each computer on your network, followed by its domain name and aliases, if any. Here's an example:

127.0.0.1 localhost.localdomain localhost
192.168.1.44 lothlorien.middle-earth.org lothlorien
192.168.1.45 bag-end.middle-earth.org bag-end
192.168.1.46 moria.middle-earth.org moria
192.168.1.47 mordor.middle-earth.org mordor

9. Save lmhosts to the same directory that contains smb.conf.

10. Exit the text editor.

11. In the terminal window, stay in superuser mode. Type the following and then press [Enter]: /etc/rc.d/init.d/smb restart

NOTE: This script, called smb, may be located in a different directory on some systems.

Now try accessing the network again. These steps should clear up the problem.