MikeyP.com MikeyP.com

FuseSMB, Localhost, and You

FuseSMB is a handy network automounting tool for Linux. It basically works like the Network Neighborhood in Windows, allowing you to browse directories shared by other computers on the network. It uses the Samba (CIFS/SMB) protocol, so it picks up shares from Windows, Mac, or Linux machines… provided those machines are configured correctly.

I've been using FuseSMB to access shared directories on my Linux server. Those directories are shared via Samba, and I can usually access them fine from Windows or Mac computers, though every once in a while, they seem to "disappear" from the network. However, when accessing them from a Linux box using FuseSMB, I had more serious issues: every 2 out of 3 times I tried to access the shares, I would get a "connection timed out" error. I naturally blamed FuseSMB for this problem until I decided to take a peek at the network using smbtree, a Samba tool for listing all Samba network connections.

2 out of 3 times using smbtree, I saw an error that my server could not be found at address 127.0.0.1. Localhost? Why was Samba looking for my server on Localhost?

I logged into my server, looked at /etc/hosts, and saw the problem. Address 127.0.0.1 was pointing at three names:


127.0.0.1     localhost
127.0.0.1     myserver.mikeyp.com myserver

These settings were just below a very detailed comment in the /etc/hosts file:


 # By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
 # should NEVER be named with the name of the machine.  It causes problems
 # for some (stupid) programs, irc and reputedly talk. :^)

Oh. I commented out the second 127.0.0.1 line, restarted the network, and my FuseSMB and Samba issues were gone.

By the way, here's something spooky about Samba. One day I fired up the VPN software on my Windows laptop to access my corporate network from home. While the laptop was connected to the VPN, I went over to my Linux box and started FuseSMB. Incredibly, on my Linux box, I could see all of the shared folders on the corporate network!

Read more stories like this one...