The FreeBSD Diary
Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link.
samba - using non-standard host names 12 June 1999
|This article shows you how to use non-standard host names. By default, samba uses the hostname of the machine on which it is running. In some situations this can cause a problem.|
|Some time ago, I installed samba and recently I
found it wasn't working. I could not see any services from my NT box. So I
went back to my original article and found a reference to the samba diagnostics.
It is frequently difficult to find the DIAGNOSIS.TXT file referred to by so many SAMBA
documents. It seems to move around the website. Hopefully this will settle down. I suggest
trying the following in the order provided:
|I started going through that diagnostic document step by step. Things started
failing on step 3:
# smbclient -L fred No interface found for address 184.108.40.206 Added interface ip=220.127.116.11 bcast=18.104.22.168 nmask=255.255.255.0 startlmhosts: Can't open lmhosts file /usr/local/etc/lmhosts. Error was No such file or directory Server time is Sat Jun 12 21:03:45 1999 Timezone is UTC+12.0 Domain=[FAB] OS=[Unix] Server=[Samba 1.9.18p8] security=share Server=[FRED] User=[root] Workgroup=[FAB] Domain=[FAB] Sharename Type Comment --------- ---- ------- backup Disk Backup directory ftp Disk ftp server file area IPC$ IPC IPC Service (Samba 1.9.18p8) lp Printer local line printer public Disk public access area root Disk Home Directories
The first step was to create /usr/local/etc/lmhosts. So I did this:
# touch /usr/local/etc/lmhosts
So onto step 4 of the diagnostics.
# nmblookup -B ducky __SAMBA__ Sending queries to 192.168.0.20 name_query failed to find name __SAMBA__
This tells me that nmbd is incorrectly installed. So I tried starting it:
# /usr/local/sbin/nmbd -D
Checking the log files I found this:
# tail /var/log/log.nmb 1999/06/12 21:44:59 netbios nameserver version 1.9.18p8 started Copyright Andrew Tridgell 1994-1997 No interface found for address 22.214.171.124 bind failed on port 137 socket_addr=126.96.36.199 (Can't assign requested address) make_subnet: Failed to open nmb socket on interface 188.8.131.52 for port 137. Error was Can't assign requested address ERROR: Failed when creating subnet lists. Exiting.
I didn't understand that. That IP address didn't belong to my box. It belonged to my router. So I started composing a message to the questions mailing list. Then I had an idea. I checked the man pages for nmbd(8). That's when it struck me: samba is using hostname. DOH! I'll explain later why this is wrong for me later.
|There was another problem with samba. It was holding outdated
information. Here's what I found in another log file:
# tail /var/log/samba/log.smb Get_Hostbyname(wocker.dvl-software.co.nz): lookup failureMatchname failed on wocker.dvl-software.co.nz 192.168.0.99 Get_Hostbyname(wocker.dvl-software.co.nz): lookup failureMatchname failed on wocker.dvl-software.co.nz 192.168.0.99 Get_Hostbyname(wocker.dvl-software.co.nz): lookup failureMatchname failed on wocker.dvl-software.co.nz 192.168.0.99 Get_Hostbyname(wocker.dvl-software.co.nz): lookup failureMatchname failed on wocker.dvl-software.co.nz 192.168.0.99 Get_Hostbyname(wocker.dvl-software.co.nz): lookup failureMatchname failed on wocker.dvl-software.co.nz 192.168.0.99 Gethostbyaddr failed for 192.168.0.99 No interface found for address 184.108.40.206
First, this hostname is long out of date. I've not used that hostname for months. And the IP address 220.127.116.11 was very out of date. My box has a DHCP connection. The IP address was quite different now. So I killed and restarted samba:
# ps -auwx | grep smb root 58 0.0 0.6 134 72 ?? Is 10Mar99 0:01.69 /usr/local/sbin/smbd -D root 663 0.0 1.4 38 180 p0 R+ 9:17PM 0:00.15 grep smb # kill -quit 358 # /usr/local/sbin/smbd -D
Then a the log file contained:
Got SIGHUP No path in service printers - using /tmp No interface found for address 18.104.22.168
Good! Now we're getting somewhere. Slowly.
|My current topology is rather unusual. If you
look up the hostname of my box, it doesn't match any of the network interfaces connected
to my box. Here's what I mean:
# ifconfig ed0 ed0: flags=c843<up,broadcast,running,simplex,link2,multicast> mtu 1500 inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255 ether 00:80:ad:df:f5:db # ifconfig ed1 ed1: flags=8843<up,broadcast,running,simplex,multicast> mtu 1500 inet 192.168.0.20 netmask 0xffffff00 broadcast 255.255.255.0 ether 00:80:ad:df:f5:d6 # hostname ns.freebsddiary.cx # nslookup ns.freebsddiary.cx Server: localhost.freebsddiary.cx Address: 127.0.0.1 Name: ns.freebsddiary.cx Address: 22.214.171.124
As you can see, neither ed0 nor ed1 matches up to the hostname of my computer. That is because 126.96.36.199 is my ADSL modem/router. That is why nmbd cannot open a socket on that address. It's on another device. [insert big grin here]
What I tried first
|Initially, I thought we could tell samba to use a name other than that
returned by hostname. Specifically, I thought that setting the following
in /usr/local/etc/smb.conf would suffice:
netbios name = fred
But I couldn't get that to work. So I took another approach.
Changing the hostname
|It's time to change the hostname of my FreeBSD box.
# hostname ns.freebsddiary.cx # hostname fred.freebsddiary.cx # hostname fred.freebsddiary.cx
All done. Now when I start nmbd, I get this in the logs:
$ tail log.nmb 1999/06/12 23:26:34 netbios nameserver version 1.9.18p8 started Copyright Andrew Tridgell 1994-1997 standard input is not a socket, assuming -D option
And a quick check shows that both smbd and nmbd are running.
# ps -auwx | grep mbd root 228 19.0 4.0 72 58 p2 R+ 11:26PM 0:00.20 grep mbd root 282 0.0 0.6 104 8 ?? Is 10:53PM 0:00.10 /usr/local/sbin/smbd -D root 225 0.2 6.0 144 86 ?? Ss 11:26PM 0:00.30 /usr/local/sbin/nmbd
Continuing with the diagnostics
|And now step 4 gives this:
# nmblookup -B fred __SAMBA__ Sending queries to 192.168.0.20 192.168.0.20 __SAMBA__<00>
That's much better! [insert sigh here]
The rest of the diagnostics proceeded without incident. samba is now running fine!
|My thanks to Andrew Tridgell of the Samba team for creating the diagnostics checklist.|