I've had Linux running at home for a little over a year. (Yea, I ran it in 1994 installing of 60 floppies but then I went "Hmmm, okay, now what?") But, with my current setup, first RH 7.3 and then RH 9.0, Samba has never worked correctly for me. It's a long story and indicative of my experience with Linux.
I got Samba installed months ago, it's not on by default nor is swat installed in RH9. Kind of lame it seems to me. I got it started and it kinda worked, I could transfer files back and forth but it would take 30 seconds to actually make a connection meaning if I tried to access the Linux box from Windows it would seriously take 30 seconds until I got a folder listing. Then, if I opened a file on the linux box from Windows in Visual Slickedit, a text editor, everytime I switched tasks and came back to Visual Slickedit I'd have to wait between 5 and 10 seconds before Slickedit would respond. It's checking the date of the file to see if it's been updated but it's having trouble.
Several times over the last 6 months or so I searched for answers for 2 or more hours on the net and never found any and I would finally just give up 😞 Finally, yesterday I remembered Oreilly's Safari service. You can pay $15 a month to have full online access to any 10 of their books per month. It's kind of convoluted but it makes some sense. For $15 a month you get 10 slots. Most books take 1 slot although some can take 1/2 a slot and others can take 2 slots. You add a book to your "bookshelf" and it takes up a slot. After 30 days you can take it off your bookshelf and get that slot back for some other book. So basically you can have access to 10 new books a month if you want.
That actually sounds like it might be a good deal. Tech books go out of date quickly and big fat tech books cost $40 to $60 so at $180 a year that's equivalent to about 4 to 5 books a year but instead you can get access to 120 books!
The first 2 weeks are free so I signed up and started reading the Samba book hoping it would tell me what's wrong. It actually didn't really tell me at first but it did help me find a problem. That problem is I have that I had no DNS and so if I typed "ping windowsbox" from the linux box it took like 10 seconds for it to figure out the IP address of "windowsbox". Why it takes 10 seconds I don't know. I added a hardcoded entry to /etc/hosts and it started working fast and so did samba.
But, that didn't actually answer my question. Windows doesn't need DNS to share and work fast. My 3 windows boxes all talk to each other just fine. And, hardcoding it in /etc/hosts is WRONG since I'm using DHCP on my hub to assign addresses there is no guarantee the address will stay the same. I wanted to fix it the correct way so that I don't need DNS, I don't need /etc/hosts AND it works fast.
I can't use DNS because no machine is always on. Sometimes it's just the notebook. Sometimes the notebook and the linux box. Sometimes my desktop only. Sometimes my desktop and my linxu box. I'm almost ready to assume that most people don't run into this problem because they are at a company and hence are running DNS and leaving the DNS box on at all times or they always turn on their linux box. I don't so I can't use DNS.
Even worse, before I looked in this book I was ready to pay Red Hat for support. Guess what, they don't support it. It was nearly impossible to figure out on their site how to pay for support and then it was clear from reading the docs that (1) they would not promise they could get samba working and (2) if they did get it working they might likely require me to add hardcoded /etc/hosts files on ALL machines instead of giving me the *correct* answer.
So much for linux support, at least through red hat.
Anyway, it took a few minutes for it to jumble around in my head and occur to
me the problem is probably where Samba is looking up the IP addresses by name
and maybe if instead of reading the troubleshooting chapter I read about Name
Resolution, maybe there is some way to tell it to use the correct option
first. So I went back to the Samba book and started reading the chapter on
Name Resolution and I found this
name resolve order = lmhosts host wins bcast
I changed it to
name resolve order = lmhosts bcast wins host
and it it got faster. That tells samba to first look in the "lmhosts" file, then try asking by broadcasting (bcast) on the net for the name, then try "wins", and finallly "hosts" means to use all the standard unix ways, ie, DNS.
I thought it was working. I removed the lines from /etc/hosts so there are no hardcoded IP addresses and I verified that I could no longer quickly ping the windowsbox from linux but samba seemed to be going fast but after rebooting Linux it turned turned out it just went from 30 second to 12 seconds and the Slickedit issue just took longer to show up.
About this time I found out that Samba book I was using on Safari is distrubuted with SWAT so I guess I didn't need safari. Again I gave up for a few days. I asked on Arstechnica in their Linux forum and was given typical hacker answers like "just hardcode it on all machines" (tell that to some admin that has to deal with hundreds or thousands of machines that each time a machine is added to the network he has to go update all machines. WRONG!) Some others suggested I needed to tell Samba to be a WINS server. They ignored what I had mentioned before, that Windows doesn't need one and that none of my machines stay on. If I made Samba be a WINS server then I would have to always have my linux box on or my Windows machines would not be able to see each other (or at least there would be a big delay as they first tried to contact the WINS server even when it was off)
I went back to thinking about name lookup and stuff and I found out a few things. One was that I did actually have DNS running. It's running in my HUB. Another is that each of the machines register themselves with the HUB through DHCP except the Linux box. It was registered as "unknown". Seeing that I tried doing an NSLOOKUP from a Windows box and found that I could get an address for all the other Windows boxes but not for the Linux box.
It took another 2 hours of digging to find out I needed to add the following 2 options to my /etc/sysconfig/network−scripts/ifcfg−eth0 file on the linux box.
"chupachupa" is the name of my Linux box. Don't ask.
Anyway, now I restarted the network on my Linux box and checked the HUB and saw that it registered itself. I tried NSLOOKUP again from a Windows box and it found the linux box's address quickly. So, that seems to be working.
I put the "name resolve order" back to
name resolve order = lmhosts host wins bcast
It turns out you can set that network stuff from the RH9 gui under Hat−>System Settings−>Network. From the devices tab you select the device, most likely "eth0" and then click "Edit". Automatically obtain IP address settings with" should be set to "dhcp" (which it was) and the below that under "DHCP settings" you should enter a hostname and set "Automatically obtain DNS information from provider". I'm sure the people the made this have their reasons for not making these things the default but because they didn't I suspect lots of newbies have no idea they need to set all this stuff.
It's still messed up though. Samba still takes 12 seconds+. Slickedit still has the 5−10 second delay. Something else I noticed also is the telneting from Windows to the Linux box takes 9 seconds before I get a prompt. Telneting from the Linux Box to itsself takes 29 seconds! But "dig chupachupa" works instantly. 😞
I'm still looking.... 😞